Search in sources :

Example 1 with FunctionStatement

use of com.twinsoft.convertigo.beans.statements.FunctionStatement 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 FunctionStatement

use of com.twinsoft.convertigo.beans.statements.FunctionStatement 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 FunctionStatement

use of com.twinsoft.convertigo.beans.statements.FunctionStatement in project convertigo by convertigo.

the class ClipboardManager method paste.

public Object paste(Node node, DatabaseObject parentDatabaseObject, boolean bChangeName) throws EngineException {
    Object object = read(node);
    if (object instanceof DatabaseObject) {
        DatabaseObject databaseObject = (DatabaseObject) object;
        String dboName = databaseObject.getName();
        String name = null;
        if (objectsType != ProjectExplorerView.TREE_OBJECT_TYPE_DBO_PROJECT) {
            // Verify if object is accepted for paste
            if (!DatabaseObjectsManager.acceptDatabaseObjects(parentDatabaseObject, databaseObject)) {
                throw new EngineException("You cannot paste to a " + parentDatabaseObject.getClass().getSimpleName() + " a database object of type " + databaseObject.getClass().getSimpleName());
            }
            if (parentDatabaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.MobileComponent) {
                if (!com.twinsoft.convertigo.beans.mobile.components.dynamic.ComponentManager.acceptDatabaseObjects(parentDatabaseObject, databaseObject)) {
                    throw new EngineException("You cannot paste to a " + parentDatabaseObject.getClass().getSimpleName() + " a database object of type " + databaseObject.getClass().getSimpleName());
                }
                if (!com.twinsoft.convertigo.beans.mobile.components.dynamic.ComponentManager.isTplCompatible(parentDatabaseObject, databaseObject)) {
                    String tplVersion = com.twinsoft.convertigo.beans.mobile.components.dynamic.ComponentManager.getTplRequired(databaseObject);
                    throw new EngineException("Template project " + tplVersion + " compatibility required");
                }
            } else if (parentDatabaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.MobileComponent) {
                if (!com.twinsoft.convertigo.beans.ngx.components.dynamic.ComponentManager.acceptDatabaseObjects(parentDatabaseObject, databaseObject)) {
                    throw new EngineException("You cannot paste to a " + parentDatabaseObject.getClass().getSimpleName() + " a database object of type " + databaseObject.getClass().getSimpleName());
                }
                if (!com.twinsoft.convertigo.beans.ngx.components.dynamic.ComponentManager.isTplCompatible(parentDatabaseObject, databaseObject)) {
                    String tplVersion = com.twinsoft.convertigo.beans.ngx.components.dynamic.ComponentManager.getTplRequired(databaseObject);
                    throw new EngineException("Template project " + tplVersion + " compatibility required");
                }
            }
            // Disable the isDefault boolean flag when the connector is pasted
            if (databaseObject instanceof Connector) {
                Connector connector = (Connector) databaseObject;
                if (connector.isDefault) {
                    connector.isDefault = false;
                }
            }
            // Disable the isRoot boolean flag when the page is pasted
            if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.PageComponent) {
                com.twinsoft.convertigo.beans.mobile.components.PageComponent page = GenericUtils.cast(databaseObject);
                if (page.isRoot) {
                    page.isRoot = false;
                }
            } else if (databaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.PageComponent) {
                com.twinsoft.convertigo.beans.ngx.components.PageComponent page = GenericUtils.cast(databaseObject);
                if (page.isRoot) {
                    page.isRoot = false;
                }
            }
            if (objectsType != ProjectExplorerView.TREE_OBJECT_TYPE_DBO_CONNECTOR) {
                // Disable the isDefault boolean flag when the transaction is pasted
                if (databaseObject instanceof Transaction) {
                    Transaction transaction = (Transaction) databaseObject;
                    if (transaction.isDefault) {
                        transaction.isDefault = false;
                    }
                }
            }
        }
        // Special case of project
        if (databaseObject instanceof Project) {
            return databaseObject;
        }
        boolean bContinue = true;
        int index = 0;
        long oldPriority = databaseObject.priority;
        // Verify if a child object with same name exist and change name
        while (bContinue) {
            if (bChangeName) {
                if (index == 0)
                    name = dboName;
                else
                    name = dboName + index;
                databaseObject.setName(name);
            }
            databaseObject.hasChanged = true;
            databaseObject.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(databaseObject);
                        find |= isInstance;
                        return isInstance;
                    }

                    @Override
                    protected void walk(DatabaseObject dbo) throws Exception {
                        if (root) {
                            root = false;
                            super.walk(dbo);
                            if (!find) {
                            // ignore: we must accept special paste: e.g. transaction over sequence
                            }
                        } else {
                            if (databaseObject.getName().equalsIgnoreCase(dbo.getName())) {
                                throw new ObjectWithSameNameException("Unable to paste the object because an object with the same name already exists in target.");
                            }
                        }
                    }
                }.init(parentDatabaseObject);
                bContinue = false;
            } catch (ObjectWithSameNameException owsne) {
                if ((parentDatabaseObject instanceof HtmlTransaction) && (databaseObject 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 paste", e);
            }
        }
        // reset ordered properties
        if (databaseObject instanceof IContainerOrdered) {
            // Mobile beans
            if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.MobileComponent) {
                if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.ApplicationComponent) {
                    com.twinsoft.convertigo.beans.mobile.components.ApplicationComponent ac = GenericUtils.cast(databaseObject);
                    ac.setOrderedRoutes(getNewOrdered());
                    ac.setOrderedMenus(getNewOrdered());
                    ac.setOrderedPages(getNewOrdered());
                    ac.setOrderedComponents(getNewOrdered());
                    ac.setOrderedSharedActions(getNewOrdered());
                    ac.setOrderedSharedComponents(getNewOrdered());
                }
                if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.RouteComponent) {
                    com.twinsoft.convertigo.beans.mobile.components.RouteComponent rc = GenericUtils.cast(databaseObject);
                    rc.setOrderedActions(getNewOrdered());
                    rc.setOrderedEvents(getNewOrdered());
                }
                if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.PageComponent) {
                    com.twinsoft.convertigo.beans.mobile.components.PageComponent pc = GenericUtils.cast(databaseObject);
                    pc.setOrderedComponents(getNewOrdered());
                }
                if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.UIComponent) {
                    com.twinsoft.convertigo.beans.mobile.components.UIComponent uic = GenericUtils.cast(databaseObject);
                    uic.setOrderedComponents(getNewOrdered());
                }
            } else if (databaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.MobileComponent) {
                if (databaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.ApplicationComponent) {
                    com.twinsoft.convertigo.beans.ngx.components.ApplicationComponent ac = GenericUtils.cast(databaseObject);
                    ac.setOrderedMenus(getNewOrdered());
                    ac.setOrderedPages(getNewOrdered());
                    ac.setOrderedComponents(getNewOrdered());
                    ac.setOrderedSharedActions(getNewOrdered());
                    ac.setOrderedSharedComponents(getNewOrdered());
                }
                if (databaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.PageComponent) {
                    com.twinsoft.convertigo.beans.ngx.components.PageComponent pc = GenericUtils.cast(databaseObject);
                    pc.setOrderedComponents(getNewOrdered());
                }
                if (databaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.UIComponent) {
                    com.twinsoft.convertigo.beans.ngx.components.UIComponent uic = GenericUtils.cast(databaseObject);
                    uic.setOrderedComponents(getNewOrdered());
                }
            }
            // Sequence beans
            if (databaseObject instanceof Sequence) {
                ((Sequence) databaseObject).setOrderedSteps(getNewOrdered());
                ((Sequence) databaseObject).setOrderedVariables(getNewOrdered());
            }
            if (databaseObject instanceof StepWithExpressions) {
                ((StepWithExpressions) databaseObject).setOrderedSteps(getNewOrdered());
            }
            if (databaseObject instanceof RequestableStep) {
                ((RequestableStep) databaseObject).setOrderedVariables(getNewOrdered());
            }
            // Transaction beans
            if (databaseObject instanceof TransactionWithVariables) {
                ((TransactionWithVariables) databaseObject).setOrderedVariables(getNewOrdered());
            }
            if (databaseObject instanceof StatementWithExpressions) {
                ((StatementWithExpressions) databaseObject).setOrderedStatements(getNewOrdered());
            }
            if (databaseObject instanceof HTTPStatement) {
                ((HTTPStatement) databaseObject).setOrderedVariables(getNewOrdered());
            }
            if (databaseObject instanceof ScreenClass) {
                ((ScreenClass) databaseObject).setOrderedCriterias(getNewOrdered());
                ((ScreenClass) databaseObject).setOrderedExtractionRules(getNewOrdered());
            }
            // TestCase bean
            if (databaseObject instanceof TestCase) {
                ((TestCase) databaseObject).setOrderedVariables(getNewOrdered());
            }
        }
        // Now add dbo to target
        try {
            if (parentDatabaseObject instanceof ScreenClass) {
                if (parentDatabaseObject instanceof JavelinScreenClass) {
                    JavelinScreenClass screenClass = (JavelinScreenClass) parentDatabaseObject;
                    if (databaseObject instanceof BlockFactory) {
                        screenClass.add(databaseObject);
                        screenClass.setBlockFactory((BlockFactory) databaseObject);
                    }
                }
                ScreenClass screenClass = (ScreenClass) parentDatabaseObject;
                if (databaseObject instanceof Criteria) {
                    if ((!screenClass.bNew) && (screenClass.equals(((IScreenClassContainer<?>) screenClass.getConnector()).getDefaultScreenClass()))) {
                        throw new EngineException("You cannot paste a new criterion to the default screen class");
                    }
                    databaseObject.priority = databaseObject.getNewOrderValue();
                    screenClass.add(databaseObject);
                } else if (databaseObject instanceof ExtractionRule) {
                    databaseObject.priority = databaseObject.getNewOrderValue();
                    screenClass.add(databaseObject);
                } else if (databaseObject instanceof Sheet) {
                    screenClass.add(databaseObject);
                } else if (databaseObject instanceof ScreenClass) {
                    databaseObject.priority = screenClass.priority + 1;
                    screenClass.add(databaseObject);
                }
            } else if (parentDatabaseObject instanceof HtmlTransaction) {
                HtmlTransaction transaction = (HtmlTransaction) parentDatabaseObject;
                if (databaseObject instanceof Sheet) {
                    transaction.add(databaseObject);
                } else if (databaseObject instanceof TestCase) {
                    transaction.add(databaseObject);
                } else if (databaseObject instanceof Variable) {
                    databaseObject.priority = databaseObject.getNewOrderValue();
                    transaction.add(databaseObject);
                } else if (databaseObject instanceof FunctionStatement) {
                    if (databaseObject instanceof StatementWithExpressions) {
                        databaseObject.priority = 0;
                    }
                    transaction.add(databaseObject);
                } else {
                    throw new EngineException("You cannot paste to an HtmlTransaction a database object of type " + databaseObject.getClass().getName());
                }
            } else if (parentDatabaseObject instanceof TransactionWithVariables) {
                TransactionWithVariables transaction = (TransactionWithVariables) parentDatabaseObject;
                if (databaseObject instanceof Sheet) {
                    transaction.add(databaseObject);
                } else if (databaseObject instanceof TestCase) {
                    transaction.add(databaseObject);
                } else if (databaseObject instanceof Variable) {
                    databaseObject.priority = databaseObject.getNewOrderValue();
                    transaction.add(databaseObject);
                }
            } else if (parentDatabaseObject instanceof Sequence) {
                Sequence sequence = (Sequence) parentDatabaseObject;
                if (databaseObject instanceof Sheet) {
                    sequence.add(databaseObject);
                } else if (databaseObject instanceof TestCase) {
                    sequence.add(databaseObject);
                } else if (databaseObject instanceof Step) {
                    databaseObject.priority = databaseObject.getNewOrderValue();
                    sequence.add(databaseObject);
                } else if (databaseObject instanceof Variable) {
                    databaseObject.priority = databaseObject.getNewOrderValue();
                    sequence.add(databaseObject);
                } else {
                    throw new EngineException("You cannot paste to a Sequence a database object of type " + databaseObject.getClass().getName());
                }
            } else if (parentDatabaseObject instanceof StatementWithExpressions) {
                StatementWithExpressions statement = (StatementWithExpressions) parentDatabaseObject;
                databaseObject.priority = databaseObject.getNewOrderValue();
                statement.add(databaseObject);
            } else if (parentDatabaseObject instanceof HTTPStatement) {
                HTTPStatement statement = (HTTPStatement) parentDatabaseObject;
                if (databaseObject instanceof Variable) {
                    databaseObject.priority = databaseObject.getNewOrderValue();
                    statement.add(databaseObject);
                }
            } else if (parentDatabaseObject instanceof StepWithExpressions) {
                StepWithExpressions step = (StepWithExpressions) parentDatabaseObject;
                databaseObject.priority = databaseObject.getNewOrderValue();
                step.add(databaseObject);
            } else if (parentDatabaseObject instanceof RequestableStep) {
                RequestableStep step = (RequestableStep) parentDatabaseObject;
                if (databaseObject instanceof Variable) {
                    databaseObject.priority = databaseObject.getNewOrderValue();
                    step.add(databaseObject);
                }
            } else if (parentDatabaseObject instanceof TestCase) {
                TestCase testCase = (TestCase) parentDatabaseObject;
                if (databaseObject instanceof Variable) {
                    databaseObject.priority = databaseObject.getNewOrderValue();
                    testCase.add(databaseObject);
                }
            } else // MOBILE COMPONENTS
            if (parentDatabaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.MobileComponent) {
                if (parentDatabaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.ApplicationComponent) {
                    com.twinsoft.convertigo.beans.mobile.components.ApplicationComponent app = GenericUtils.cast(parentDatabaseObject);
                    if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.PageComponent) {
                        databaseObject.priority = databaseObject.getNewOrderValue();
                        app.add(databaseObject);
                    } else if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.RouteComponent) {
                        databaseObject.priority = databaseObject.getNewOrderValue();
                        app.add(databaseObject);
                    } else if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.UIDynamicMenu) {
                        databaseObject.priority = databaseObject.getNewOrderValue();
                        app.add(databaseObject);
                    } else if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.UIComponent) {
                        databaseObject.priority = databaseObject.getNewOrderValue();
                        app.add(databaseObject);
                    }
                } else if (parentDatabaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.RouteComponent) {
                    com.twinsoft.convertigo.beans.mobile.components.RouteComponent route = GenericUtils.cast(parentDatabaseObject);
                    if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.RouteActionComponent) {
                        databaseObject.priority = databaseObject.getNewOrderValue();
                        com.twinsoft.convertigo.beans.mobile.components.RouteActionComponent rac = GenericUtils.cast(databaseObject);
                        int i = rac.getPage().lastIndexOf(".");
                        if (i != -1) {
                            String pageName = rac.getPage().substring(i);
                            String pageQName = route.getParent().getQName() + pageName;
                            rac.setPage(pageQName);
                        }
                        route.add(rac);
                    } else if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.RouteEventComponent) {
                        databaseObject.priority = databaseObject.getNewOrderValue();
                        route.add(databaseObject);
                    }
                } else if (parentDatabaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.PageComponent) {
                    com.twinsoft.convertigo.beans.mobile.components.PageComponent page = GenericUtils.cast(parentDatabaseObject);
                    if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.UIComponent) {
                        databaseObject.priority = databaseObject.getNewOrderValue();
                        page.add(databaseObject);
                    }
                } else if (parentDatabaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.UIDynamicMenu) {
                    com.twinsoft.convertigo.beans.mobile.components.UIDynamicMenu menu = GenericUtils.cast(parentDatabaseObject);
                    if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.UIComponent) {
                        databaseObject.priority = databaseObject.getNewOrderValue();
                        menu.add(databaseObject);
                    }
                } else if (parentDatabaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.UIComponent) {
                    com.twinsoft.convertigo.beans.mobile.components.UIComponent component = GenericUtils.cast(parentDatabaseObject);
                    databaseObject.priority = databaseObject.getNewOrderValue();
                    component.add(databaseObject);
                }
            } else // NGX COMPONENTS
            if (parentDatabaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.MobileComponent) {
                if (parentDatabaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.ApplicationComponent) {
                    com.twinsoft.convertigo.beans.ngx.components.ApplicationComponent app = GenericUtils.cast(parentDatabaseObject);
                    if (databaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.PageComponent) {
                        databaseObject.priority = databaseObject.getNewOrderValue();
                        app.add(databaseObject);
                    } else if (databaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.UIDynamicMenu) {
                        databaseObject.priority = databaseObject.getNewOrderValue();
                        app.add(databaseObject);
                    } else if (databaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.UIComponent) {
                        databaseObject.priority = databaseObject.getNewOrderValue();
                        app.add(databaseObject);
                    }
                } else if (parentDatabaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.PageComponent) {
                    com.twinsoft.convertigo.beans.ngx.components.PageComponent page = GenericUtils.cast(parentDatabaseObject);
                    if (databaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.UIComponent) {
                        databaseObject.priority = databaseObject.getNewOrderValue();
                        page.add(databaseObject);
                    }
                } else if (parentDatabaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.UIDynamicMenu) {
                    com.twinsoft.convertigo.beans.ngx.components.UIDynamicMenu menu = GenericUtils.cast(parentDatabaseObject);
                    if (databaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.UIComponent) {
                        databaseObject.priority = databaseObject.getNewOrderValue();
                        menu.add(databaseObject);
                    }
                } else if (parentDatabaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.UIComponent) {
                    com.twinsoft.convertigo.beans.ngx.components.UIComponent component = GenericUtils.cast(parentDatabaseObject);
                    databaseObject.priority = databaseObject.getNewOrderValue();
                    component.add(databaseObject);
                }
            } else if (parentDatabaseObject == null) {
                if (databaseObject instanceof Project) {
                    if (Engine.theApp.databaseObjectsManager.existsProject(databaseObject.getName())) {
                        throw new ObjectWithSameNameException("Project already exist!");
                    }
                }
            } else {
                parentDatabaseObject.add(databaseObject);
            }
        } catch (ObjectWithSameNameException owsne) {
            if ((parentDatabaseObject instanceof HtmlTransaction) && (databaseObject instanceof Statement)) {
                throw new EngineException("HtmlTransaction already contains a statement named \"" + name + "\".", owsne);
            }
            if ((parentDatabaseObject instanceof Sequence) && (databaseObject instanceof Step)) {
                throw new EngineException("Sequence already contains a step named \"" + name + "\".", owsne);
            }
        }
        NodeList childNodes = node.getChildNodes();
        int len = childNodes.getLength();
        Node childNode;
        String childNodeName;
        for (int i = 0; i < len; i++) {
            childNode = childNodes.item(i);
            if (childNode.getNodeType() != Node.ELEMENT_NODE) {
                continue;
            }
            childNodeName = childNode.getNodeName();
            if (!(childNodeName.equalsIgnoreCase("property")) && !(childNodeName.equalsIgnoreCase("handlers")) && !(childNodeName.equalsIgnoreCase("wsdltype")) && !(childNodeName.equalsIgnoreCase("docdata")) && !(childNodeName.equalsIgnoreCase("dnd"))) {
                paste(childNode, databaseObject, bChangeName);
            }
        }
        // For update of sources which reference this step
        if (databaseObject instanceof Step) {
            pastedSteps.put(String.valueOf(oldPriority), (Step) databaseObject);
        }
        // For update of sources which reference this mobile component
        if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.MobileComponent) {
            if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.IAction || databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.UIActionStack || databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.UIControlDirective || databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.UIForm || databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.UISharedComponent) {
                pastedComponents.put(String.valueOf(oldPriority), GenericUtils.cast(databaseObject));
            }
        } else if (databaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.MobileComponent) {
            if (databaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.IAction || databaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.UIActionStack || databaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.UIControlDirective || databaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.UIForm || databaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.UISharedComponent) {
                pastedComponents.put(String.valueOf(oldPriority), GenericUtils.cast(databaseObject));
            }
        }
        // needed
        databaseObject.isImporting = false;
        databaseObject.isSubLoaded = true;
        return databaseObject;
    } else if (object instanceof JsonData) {
        if (parentDatabaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.MobileComponent) {
            if (parentDatabaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.UIPageEvent || parentDatabaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.UIAppEvent || parentDatabaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.UIDynamicAction || parentDatabaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.UIActionStack) {
                JsonData jsonData = (JsonData) object;
                JSONObject json = jsonData.getData();
                if (json.has("qname")) {
                    try {
                        com.twinsoft.convertigo.beans.mobile.components.UIComponent uiComponent = GenericUtils.cast(parentDatabaseObject);
                        DatabaseObject call = com.twinsoft.convertigo.beans.mobile.components.dynamic.ComponentManager.createBean(com.twinsoft.convertigo.beans.mobile.components.dynamic.ComponentManager.getComponentByName("FullSyncViewAction"));
                        if (call != null && call instanceof com.twinsoft.convertigo.beans.mobile.components.UIDynamicAction) {
                            com.twinsoft.convertigo.beans.mobile.components.UIDynamicAction dynAction = GenericUtils.cast(call);
                            com.twinsoft.convertigo.beans.mobile.components.dynamic.IonBean ionBean = dynAction.getIonBean();
                            if (ionBean != null && ionBean.hasProperty("fsview")) {
                                call.bNew = true;
                                call.hasChanged = true;
                                ionBean.setPropertyValue("fsview", new com.twinsoft.convertigo.beans.mobile.components.MobileSmartSourceType(json.getString("qname")));
                                uiComponent.add(call);
                                uiComponent.hasChanged = true;
                            }
                            return call;
                        }
                    } catch (JSONException e) {
                        Engine.logStudio.warn("Failed to create a FullSyncViewAction", e);
                    }
                }
            }
        } else if (parentDatabaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.MobileComponent) {
            if (parentDatabaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.UIPageEvent || parentDatabaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.UIAppEvent || parentDatabaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.UIDynamicAction || parentDatabaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.UIActionStack) {
                JsonData jsonData = (JsonData) object;
                JSONObject json = jsonData.getData();
                if (json.has("qname")) {
                    try {
                        com.twinsoft.convertigo.beans.ngx.components.UIComponent uiComponent = GenericUtils.cast(parentDatabaseObject);
                        DatabaseObject call = com.twinsoft.convertigo.beans.ngx.components.dynamic.ComponentManager.createBean(com.twinsoft.convertigo.beans.ngx.components.dynamic.ComponentManager.getComponentByName("FullSyncViewAction"));
                        if (call != null && call instanceof com.twinsoft.convertigo.beans.ngx.components.UIDynamicAction) {
                            com.twinsoft.convertigo.beans.ngx.components.UIDynamicAction dynAction = GenericUtils.cast(call);
                            com.twinsoft.convertigo.beans.ngx.components.dynamic.IonBean ionBean = dynAction.getIonBean();
                            if (ionBean != null && ionBean.hasProperty("fsview")) {
                                call.bNew = true;
                                call.hasChanged = true;
                                ionBean.setPropertyValue("fsview", new com.twinsoft.convertigo.beans.ngx.components.MobileSmartSourceType(json.getString("qname")));
                                uiComponent.add(call);
                                uiComponent.hasChanged = true;
                            }
                            return call;
                        }
                    } catch (JSONException e) {
                        Engine.logStudio.warn("Failed to create a FullSyncViewAction", e);
                    }
                }
            }
        }
    }
    return null;
}
Also used : BlockFactory(com.twinsoft.convertigo.beans.core.BlockFactory) JavelinScreenClass(com.twinsoft.convertigo.beans.screenclasses.JavelinScreenClass) ScreenClass(com.twinsoft.convertigo.beans.core.ScreenClass) Node(org.w3c.dom.Node) EngineException(com.twinsoft.convertigo.engine.EngineException) StepWithExpressions(com.twinsoft.convertigo.beans.core.StepWithExpressions) HTTPStatement(com.twinsoft.convertigo.beans.statements.HTTPStatement) FunctionStatement(com.twinsoft.convertigo.beans.statements.FunctionStatement) StatementWithExpressions(com.twinsoft.convertigo.beans.core.StatementWithExpressions) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) JavelinScreenClass(com.twinsoft.convertigo.beans.screenclasses.JavelinScreenClass) NodeList(org.w3c.dom.NodeList) Sequence(com.twinsoft.convertigo.beans.core.Sequence) Project(com.twinsoft.convertigo.beans.core.Project) Transaction(com.twinsoft.convertigo.beans.core.Transaction) HtmlTransaction(com.twinsoft.convertigo.beans.transactions.HtmlTransaction) JSONObject(org.codehaus.jettison.json.JSONObject) RequestableStep(com.twinsoft.convertigo.beans.core.RequestableStep) IContainerOrdered(com.twinsoft.convertigo.beans.core.IContainerOrdered) IPropertyTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IPropertyTreeObject) RequestableObject(com.twinsoft.convertigo.beans.core.RequestableObject) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) JSONObject(org.codehaus.jettison.json.JSONObject) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) IDesignTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IDesignTreeObject) MobileObject(com.twinsoft.convertigo.beans.core.MobileObject) Connector(com.twinsoft.convertigo.beans.core.Connector) Variable(com.twinsoft.convertigo.beans.core.Variable) ExtractionRule(com.twinsoft.convertigo.beans.core.ExtractionRule) WalkHelper(com.twinsoft.convertigo.engine.helpers.WalkHelper) Criteria(com.twinsoft.convertigo.beans.core.Criteria) 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) ElseStatement(com.twinsoft.convertigo.beans.statements.ElseStatement) FunctionStatement(com.twinsoft.convertigo.beans.statements.FunctionStatement) HTTPStatement(com.twinsoft.convertigo.beans.statements.HTTPStatement) Statement(com.twinsoft.convertigo.beans.core.Statement) ThenStatement(com.twinsoft.convertigo.beans.statements.ThenStatement) HtmlTransaction(com.twinsoft.convertigo.beans.transactions.HtmlTransaction) JSONException(org.codehaus.jettison.json.JSONException) SAXException(org.xml.sax.SAXException) EngineException(com.twinsoft.convertigo.engine.EngineException) ConvertigoException(com.twinsoft.convertigo.engine.ConvertigoException) IOException(java.io.IOException) JSONException(org.codehaus.jettison.json.JSONException) InvalidOperationException(com.twinsoft.convertigo.engine.InvalidOperationException) ObjectWithSameNameException(com.twinsoft.convertigo.engine.ObjectWithSameNameException) ObjectWithSameNameException(com.twinsoft.convertigo.engine.ObjectWithSameNameException) TestCase(com.twinsoft.convertigo.beans.core.TestCase) TransactionWithVariables(com.twinsoft.convertigo.beans.core.TransactionWithVariables) Sheet(com.twinsoft.convertigo.beans.core.Sheet)

Example 4 with FunctionStatement

use of com.twinsoft.convertigo.beans.statements.FunctionStatement in project convertigo by convertigo.

the class ReferencesView method handleConnectorSelection.

private void handleConnectorSelection(Object firstElement) {
    ConnectorTreeObject connectorTreeObject = (ConnectorTreeObject) firstElement;
    Connector connectorSelected = connectorTreeObject.getObject();
    String connectorSelectedName = connectorSelected.getName();
    Project projectConnectorSelected = connectorSelected.getProject();
    String connectorProjectName = connectorSelected.getProject().getName();
    List<Transaction> transactions = connectorSelected.getTransactionsList();
    try {
        Project project = null;
        List<String> projectNames = Engine.theApp.databaseObjectsManager.getAllProjectNamesList();
        ProjectExplorerView projectExplorerView = ConvertigoPlugin.getDefault().getProjectExplorerView();
        treeViewer.setInput(null);
        RootNode root = new RootNode();
        ConnectorNode connectorNode = null;
        connectorNode = getConnectorNode(root, connectorSelected);
        root.addChild(connectorNode);
        IsUsedByNode isUsedByNode = new IsUsedByNode(connectorNode, "Is used by");
        RequiresNode requiresNode = new RequiresNode(connectorNode, "Requires");
        ProjectNode projectFolder = null;
        // Search handlers are that referenced by the selected connector for continue with site Clipper
        if (connectorSelected instanceof HtmlConnector) {
            ProjectNode projectNode = new ProjectNode(requiresNode, connectorProjectName, projectConnectorSelected);
            for (Transaction transaction : transactions) {
                List<Statement> statements = ((HtmlTransaction) transaction).getStatements();
                List<String> siteClipperConnectorNames = new ArrayList<String>();
                for (Statement statement : statements) {
                    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 = projectConnectorSelected.getConnectorByName(siteClipperconnectorName);
                                ConnectorNode connectorSiteClipperNode = new SiteClipperConnectorNode(projectNode, siteClipperconnectorName, siteClipperConnector);
                                projectNode.addChild(connectorSiteClipperNode);
                            }
                        }
                    }
                }
            }
            if (projectNode.hasChildren()) {
                requiresNode.addChild(projectNode);
            }
        } else if (connectorSelected instanceof SiteClipperConnector) {
            List<Connector> connectors = projectConnectorSelected.getConnectorsList();
            ProjectNode projectNode = new ProjectNode(isUsedByNode, connectorProjectName, projectConnectorSelected);
            for (Connector connector : connectors) {
                if (connector instanceof HtmlConnector) {
                    List<Transaction> transactionList = ((HtmlConnector) connector).getTransactionsList();
                    for (Transaction transaction : transactionList) {
                        List<Statement> statements = ((HtmlTransaction) transaction).getStatements();
                        for (Statement statement : statements) {
                            List<Statement> statementList = ((FunctionStatement) statement).getStatements();
                            for (Statement st : statementList) {
                                if (st instanceof ContinueWithSiteClipperStatement) {
                                    String sourceSiteClipperConnectorName = ((ContinueWithSiteClipperStatement) st).getSiteClipperConnectorName();
                                    if (sourceSiteClipperConnectorName.equals(connectorSelectedName)) {
                                        ContinueWithSiteClipperStatement continueWithSiteClipperStatement = (ContinueWithSiteClipperStatement) st;
                                        HtmlConnectorNode htmlConnectorNode = new HtmlConnectorNode(projectNode, connector.getName(), connector);
                                        projectNode.addChild(htmlConnectorNode);
                                        TransactionNode transactionNode = new TransactionNode(htmlConnectorNode, transaction.getName(), continueWithSiteClipperStatement);
                                        htmlConnectorNode.addChild(transactionNode);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            if (projectNode.hasChildren()) {
                isUsedByNode.addChild(projectNode);
            }
        }
        // Searching all objects that are referenced by the selected connector
        for (String projectName : projectNames) {
            project = getProject(projectName, projectExplorerView);
            if (project != null) {
                projectFolder = new ProjectNode(isUsedByNode, projectName, 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.startsWith(projectConnectorSelected + "." + connectorSelectedName + ".")) {
                                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> steps = sequence.getSteps();
                    SequenceNode sequenceNode = new SequenceNode(projectFolder, sequence.getName(), sequence);
                    for (Step step : steps) {
                        getConnectorReferencingIsUsedBy(step, projectExplorerView, sequenceNode, transactions, connectorProjectName, connectorSelectedName);
                    }
                    if (sequenceNode.hasChildren()) {
                        projectFolder.addChild(sequenceNode);
                    }
                }
                if (projectFolder.hasChildren()) {
                    isUsedByNode.addChild(projectFolder);
                }
            }
        }
        if (requiresNode.hasChildren()) {
            connectorNode.addChild(requiresNode);
        }
        if (isUsedByNode.hasChildren()) {
            connectorNode.addChild(isUsedByNode);
        }
        if (!connectorNode.hasChildren()) {
            connectorNode.addChild(new InformationNode(connectorNode, "This connector is not used by any other objects"));
        }
        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) 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) ContinueWithSiteClipperStatement(com.twinsoft.convertigo.beans.statements.ContinueWithSiteClipperStatement) MapperNode(com.twinsoft.convertigo.eclipse.views.references.model.MapperNode) 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) FunctionStatement(com.twinsoft.convertigo.beans.statements.FunctionStatement) SiteClipperConnector(com.twinsoft.convertigo.beans.connectors.SiteClipperConnector) HtmlConnectorNode(com.twinsoft.convertigo.eclipse.views.references.model.HtmlConnectorNode) 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) 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) ConnectorTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ConnectorTreeObject) Project(com.twinsoft.convertigo.beans.core.Project) 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) IsUsedByNode(com.twinsoft.convertigo.eclipse.views.references.model.IsUsedByNode) RequiresNode(com.twinsoft.convertigo.eclipse.views.references.model.RequiresNode) TransactionNode(com.twinsoft.convertigo.eclipse.views.references.model.TransactionNode) ProjectNode(com.twinsoft.convertigo.eclipse.views.references.model.ProjectNode)

Example 5 with FunctionStatement

use of com.twinsoft.convertigo.beans.statements.FunctionStatement in project convertigo by convertigo.

the class ObjectInfoWizardPage method dialogChanged.

private void dialogChanged(boolean increment) {
    DatabaseObject dbo = ((ObjectExplorerWizardPage) getWizard().getPage("ObjectExplorerWizardPage")).getCreatedBean();
    if (dbo instanceof FunctionStatement) {
        beanName.setEnabled(true);
        if (dbo instanceof HandlerStatement) {
            beanName.setEnabled(false);
        }
    }
    String name = getBeanName();
    if (name.length() == 0) {
        updateStatus("Name must be specified");
        return;
    }
    if (!StringUtils.isNormalized(name)) {
        updateStatus("Name must be normalized.\nDon't start with number and don't use non ASCII caracters");
        return;
    }
    Matcher m = Pattern.compile("\\d+$").matcher("");
    boolean sameName;
    do {
        sameName = false;
        try {
            dbo.setName(name);
            if (treeItemName != null) {
                if (dbo instanceof ScHandlerStatement)
                    ((ScHandlerStatement) dbo).setNormalizedScreenClassName(treeItemName);
                else if (dbo instanceof HandlerStatement)
                    ((HandlerStatement) dbo).setHandlerType(treeItemName);
            }
        } catch (ObjectWithSameNameException e) {
            if (!increment) {
                updateStatus("Name already used by siblings");
                return;
            }
            sameName = true;
            m.reset(name);
            if (m.find()) {
                name = name.substring(0, m.start()) + (Integer.parseInt(m.group()) + 1);
            } else {
                name = name + "_1";
            }
            setBeanName(name);
        } catch (EngineException e) {
            updateStatus("Name could not be set on bean");
            return;
        } catch (NullPointerException e) {
            updateStatus("New Bean has not been instanciated");
            return;
        }
    } while (sameName);
    updateStatus(null);
}
Also used : FunctionStatement(com.twinsoft.convertigo.beans.statements.FunctionStatement) ObjectWithSameNameException(com.twinsoft.convertigo.engine.ObjectWithSameNameException) Matcher(java.util.regex.Matcher) EngineException(com.twinsoft.convertigo.engine.EngineException) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) 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) ScHandlerStatement(com.twinsoft.convertigo.beans.statements.ScHandlerStatement)

Aggregations

FunctionStatement (com.twinsoft.convertigo.beans.statements.FunctionStatement)5 EngineException (com.twinsoft.convertigo.engine.EngineException)5 Statement (com.twinsoft.convertigo.beans.core.Statement)4 ScHandlerStatement (com.twinsoft.convertigo.beans.statements.ScHandlerStatement)4 SiteClipperConnector (com.twinsoft.convertigo.beans.connectors.SiteClipperConnector)3 Connector (com.twinsoft.convertigo.beans.core.Connector)3 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)3 Project (com.twinsoft.convertigo.beans.core.Project)3 RequestableStep (com.twinsoft.convertigo.beans.core.RequestableStep)3 ScreenClass (com.twinsoft.convertigo.beans.core.ScreenClass)3 Sequence (com.twinsoft.convertigo.beans.core.Sequence)3 Step (com.twinsoft.convertigo.beans.core.Step)3 Transaction (com.twinsoft.convertigo.beans.core.Transaction)3 ContinueWithSiteClipperStatement (com.twinsoft.convertigo.beans.statements.ContinueWithSiteClipperStatement)3 ElseStep (com.twinsoft.convertigo.beans.steps.ElseStep)3 ThenStep (com.twinsoft.convertigo.beans.steps.ThenStep)3 HtmlTransaction (com.twinsoft.convertigo.beans.transactions.HtmlTransaction)3 CicsConnector (com.twinsoft.convertigo.beans.connectors.CicsConnector)2 HtmlConnector (com.twinsoft.convertigo.beans.connectors.HtmlConnector)2 HttpConnector (com.twinsoft.convertigo.beans.connectors.HttpConnector)2