Search in sources :

Example 1 with Sequence

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

the class ClipboardAction method pasteStep.

private Object pasteStep(Shell shell, String source, DatabaseObject targetObject) throws ParserConfigurationException, SAXException, IOException {
    // Can only paste on Sequence or Step
    if (targetObject instanceof Sequence)
        return targetObject;
    else if (!(targetObject instanceof Step))
        return null;
    // cannot paste to IThenElseContainer
    if (targetObject instanceof IThenElseContainer)
        return null;
    else {
        List<Object> objects = clipboardManager.read(source);
        int size = objects.size();
        for (Object ob : objects) {
            // Can only paste step objects
            if (!(ob instanceof Step))
                return null;
            // Can paste only on step which may contain children
            if ((ob instanceof StepWithExpressions) && (!(targetObject instanceof StepWithExpressions)))
                return null;
            // cannot paste a ThenStep
            if (ob instanceof ThenStep)
                return null;
            // cannot paste a ElseStep
            if (ob instanceof ElseStep)
                return null;
            // cannot paste a ThenStatement
            if (ob instanceof ThenStatement)
                return null;
            // cannot paste a ElseStatement
            if (ob instanceof ElseStatement)
                return null;
            // Special case of XMLElementStep, ElementStep
            if ((targetObject instanceof XMLElementStep) || (targetObject instanceof ElementStep)) {
                // Case paste on itself -> target is changed to parent
                if ((size == 1) && ((ob instanceof XMLElementStep) || (ob instanceof ElementStep))) {
                    if (((Step) ob).getName().equals(targetObject.getName())) {
                        return targetObject.getParent();
                    }
                    return null;
                } else // Else, only accept paste of XMLAttributeStep
                if (!(ob instanceof XMLAttributeStep || ob instanceof AttributeStep)) {
                    return null;
                }
            } else // Case of step which may contain children
            if (targetObject instanceof StepWithExpressions) {
                // Case paste on itself -> ask user what to do
                if ((size == 1) && (ob.getClass().equals(targetObject.getClass()))) {
                    if (((Step) ob).getName().equals(targetObject.getName())) {
                        CustomDialog customDialog = new CustomDialog(shell, "Paste a step", "Do you want to paste the step as a sibling or a child step?", 500, 150, new ButtonSpec("As a sibling", true), new ButtonSpec("As a child", false), new ButtonSpec(IDialogConstants.CANCEL_LABEL, false));
                        int response = customDialog.open();
                        if (response == 0) {
                            return targetObject.getParent();
                        } else if (response == 2) {
                            return null;
                        } else
                            break;
                    }
                }
                // Else, paste
                break;
            } else // Other case
            {
                // Case paste on itself -> target is changed to parent
                if ((size == 1) && (ob.getClass().equals(targetObject.getClass()))) {
                    if (((Step) ob).getName().equals(targetObject.getName())) {
                        return targetObject.getParent();
                    }
                    return null;
                }
                // Else, not permitted
                return null;
            }
        }
    }
    return targetObject;
}
Also used : IThenElseContainer(com.twinsoft.convertigo.beans.steps.IThenElseContainer) ElseStep(com.twinsoft.convertigo.beans.steps.ElseStep) XMLElementStep(com.twinsoft.convertigo.beans.steps.XMLElementStep) StepWithExpressions(com.twinsoft.convertigo.beans.core.StepWithExpressions) ThenStatement(com.twinsoft.convertigo.beans.statements.ThenStatement) Sequence(com.twinsoft.convertigo.beans.core.Sequence) ThenStep(com.twinsoft.convertigo.beans.steps.ThenStep) XMLAttributeStep(com.twinsoft.convertigo.beans.steps.XMLAttributeStep) Step(com.twinsoft.convertigo.beans.core.Step) ElementStep(com.twinsoft.convertigo.beans.steps.ElementStep) XMLElementStep(com.twinsoft.convertigo.beans.steps.XMLElementStep) ElseStep(com.twinsoft.convertigo.beans.steps.ElseStep) AttributeStep(com.twinsoft.convertigo.beans.steps.AttributeStep) XMLAttributeStep(com.twinsoft.convertigo.beans.steps.XMLAttributeStep) ThenStep(com.twinsoft.convertigo.beans.steps.ThenStep) CustomDialog(com.twinsoft.convertigo.eclipse.dialogs.CustomDialog) ElseStatement(com.twinsoft.convertigo.beans.statements.ElseStatement) XMLAttributeStep(com.twinsoft.convertigo.beans.steps.XMLAttributeStep) AttributeStep(com.twinsoft.convertigo.beans.steps.AttributeStep) IPropertyTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IPropertyTreeObject) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) ProjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ProjectTreeObject) IDesignTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IDesignTreeObject) FolderTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.FolderTreeObject) ElementStep(com.twinsoft.convertigo.beans.steps.ElementStep) XMLElementStep(com.twinsoft.convertigo.beans.steps.XMLElementStep) ButtonSpec(com.twinsoft.convertigo.eclipse.dialogs.ButtonSpec)

Example 2 with Sequence

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

the class ChangeToSingleValuedVariableAction method run.

@Override
public void run() {
    Display display = Display.getDefault();
    Cursor waitCursor = new Cursor(display, SWT.CURSOR_WAIT);
    Shell shell = getParentShell();
    shell.setCursor(waitCursor);
    try {
        ProjectExplorerView explorerView = getProjectExplorerView();
        if (explorerView != null) {
            TreeObject treeObject = explorerView.getFirstSelectedTreeObject();
            TreeParent treeParent = treeObject.getParent();
            DatabaseObjectTreeObject parentTreeObject = null;
            if (treeParent instanceof DatabaseObjectTreeObject)
                parentTreeObject = (DatabaseObjectTreeObject) treeParent;
            else
                parentTreeObject = (DatabaseObjectTreeObject) treeParent.getParent();
            if (parentTreeObject != null) {
                Object databaseObject = treeObject.getObject();
                if (databaseObject != null) {
                    Variable multi = (Variable) databaseObject;
                    Variable simple = null;
                    if (databaseObject instanceof TestCaseMultiValuedVariable)
                        simple = new TestCaseVariable();
                    if (databaseObject instanceof StepMultiValuedVariable)
                        simple = new StepVariable();
                    if (databaseObject instanceof RequestableMultiValuedVariable)
                        simple = new RequestableVariable();
                    if (databaseObject instanceof RequestableHttpMultiValuedVariable)
                        simple = new RequestableHttpVariable();
                    if (databaseObject instanceof HttpStatementMultiValuedVariable)
                        simple = new HttpStatementVariable();
                    if (simple != null) {
                        if (multi instanceof StepMultiValuedVariable) {
                            ((StepVariable) simple).setSourceDefinition(((StepVariable) multi).getSourceDefinition());
                        }
                        if (multi instanceof RequestableVariable) {
                            ((RequestableVariable) simple).setXmlTypeAffectation(((RequestableVariable) multi).getXmlTypeAffectation());
                        }
                        if (multi instanceof RequestableHttpVariable) {
                            // HttpName
                            ((RequestableHttpVariable) simple).setHttpName(((RequestableHttpVariable) multi).getHttpName());
                            // HttpMethod
                            ((RequestableHttpVariable) simple).setHttpMethod(((RequestableHttpVariable) multi).getHttpMethod());
                        }
                        XMLVector<Object> xmlv = GenericUtils.cast(multi.getValueOrNull());
                        Object value = (xmlv == null) ? null : (xmlv.isEmpty() ? "" : xmlv.get(0).toString());
                        simple.setValueOrNull(value);
                        simple.setVisibility(multi.getVisibility());
                        // Comment
                        simple.setComment(multi.getComment());
                        // Description
                        simple.setDescription(multi.getDescription());
                        // Required
                        simple.setRequired(multi.isRequired());
                        simple.bNew = true;
                        simple.hasChanged = true;
                        // Add new variable to parent
                        DatabaseObject parentDbo = multi.getParent();
                        parentDbo.add(simple);
                        // Set correct order
                        if (parentDbo instanceof TestCase)
                            ((TestCase) parentDbo).insertAtOrder(simple, multi.priority);
                        if (parentDbo instanceof RequestableStep)
                            ((RequestableStep) parentDbo).insertAtOrder(simple, multi.priority);
                        if (parentDbo instanceof Sequence)
                            ((Sequence) parentDbo).insertAtOrder(simple, multi.priority);
                        if (parentDbo instanceof TransactionWithVariables)
                            ((TransactionWithVariables) parentDbo).insertAtOrder(simple, multi.priority);
                        if (parentDbo instanceof HTTPStatement)
                            ((HTTPStatement) parentDbo).insertAtOrder(simple, multi.priority);
                        // Add new variable in Tree
                        VariableTreeObject2 varTreeObject = new VariableTreeObject2(explorerView.viewer, simple);
                        treeParent.addChild(varTreeObject);
                        // Delete simple variable
                        multi.delete();
                        // Set correct name
                        simple.setName(multi.getName());
                        parentTreeObject.hasBeenModified(true);
                        explorerView.reloadTreeObject(parentTreeObject);
                        explorerView.setSelectedTreeObject(explorerView.findTreeObjectByUserObject(simple));
                    }
                }
            }
        }
    } catch (Throwable e) {
        ConvertigoPlugin.logException(e, "Unable to change simple variable to multi valuated variable!");
    } finally {
        shell.setCursor(null);
        waitCursor.dispose();
    }
}
Also used : RequestableHttpVariable(com.twinsoft.convertigo.beans.variables.RequestableHttpVariable) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) RequestableMultiValuedVariable(com.twinsoft.convertigo.beans.variables.RequestableMultiValuedVariable) RequestableHttpVariable(com.twinsoft.convertigo.beans.variables.RequestableHttpVariable) HttpStatementVariable(com.twinsoft.convertigo.beans.variables.HttpStatementVariable) TestCaseVariable(com.twinsoft.convertigo.beans.variables.TestCaseVariable) HttpStatementMultiValuedVariable(com.twinsoft.convertigo.beans.variables.HttpStatementMultiValuedVariable) Variable(com.twinsoft.convertigo.beans.core.Variable) StepVariable(com.twinsoft.convertigo.beans.variables.StepVariable) StepMultiValuedVariable(com.twinsoft.convertigo.beans.variables.StepMultiValuedVariable) TestCaseMultiValuedVariable(com.twinsoft.convertigo.beans.variables.TestCaseMultiValuedVariable) RequestableVariable(com.twinsoft.convertigo.beans.variables.RequestableVariable) RequestableHttpMultiValuedVariable(com.twinsoft.convertigo.beans.variables.RequestableHttpMultiValuedVariable) TreeParent(com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeParent) HttpStatementMultiValuedVariable(com.twinsoft.convertigo.beans.variables.HttpStatementMultiValuedVariable) StepVariable(com.twinsoft.convertigo.beans.variables.StepVariable) Cursor(org.eclipse.swt.graphics.Cursor) HTTPStatement(com.twinsoft.convertigo.beans.statements.HTTPStatement) StepMultiValuedVariable(com.twinsoft.convertigo.beans.variables.StepMultiValuedVariable) Shell(org.eclipse.swt.widgets.Shell) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) VariableTreeObject2(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.VariableTreeObject2) ProjectExplorerView(com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView) RequestableVariable(com.twinsoft.convertigo.beans.variables.RequestableVariable) Sequence(com.twinsoft.convertigo.beans.core.Sequence) HttpStatementVariable(com.twinsoft.convertigo.beans.variables.HttpStatementVariable) TestCaseVariable(com.twinsoft.convertigo.beans.variables.TestCaseVariable) TestCaseMultiValuedVariable(com.twinsoft.convertigo.beans.variables.TestCaseMultiValuedVariable) RequestableHttpMultiValuedVariable(com.twinsoft.convertigo.beans.variables.RequestableHttpMultiValuedVariable) TestCase(com.twinsoft.convertigo.beans.core.TestCase) RequestableStep(com.twinsoft.convertigo.beans.core.RequestableStep) RequestableMultiValuedVariable(com.twinsoft.convertigo.beans.variables.RequestableMultiValuedVariable) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) TransactionWithVariables(com.twinsoft.convertigo.beans.core.TransactionWithVariables) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) Display(org.eclipse.swt.widgets.Display)

Example 3 with Sequence

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

the class CreateStubFromXMLAction method getXML.

public Document getXML(TreeObject treeObject) throws Exception {
    Document dom = XMLUtils.createDom("java");
    ProjectTreeObject projectTreeObject = treeObject.getProjectTreeObject();
    Object requestable = treeObject.getObject();
    if (requestable instanceof Transaction) {
        Transaction transaction = (Transaction) requestable;
        ConnectorEditor connectorEditor = projectTreeObject.getConnectorEditor((Connector) transaction.getParent());
        dom = connectorEditor.getLastGeneratedDocument();
    } else if (requestable instanceof Sequence) {
        SequenceEditor sequenceEditor = projectTreeObject.getSequenceEditor((Sequence) requestable);
        dom = sequenceEditor.getLastGeneratedDocument();
    }
    if (dom == null) {
        throw new NoSuchElementException();
    }
    return dom;
}
Also used : Transaction(com.twinsoft.convertigo.beans.core.Transaction) ProjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ProjectTreeObject) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) ProjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ProjectTreeObject) Sequence(com.twinsoft.convertigo.beans.core.Sequence) SequenceEditor(com.twinsoft.convertigo.eclipse.editors.sequence.SequenceEditor) Document(org.w3c.dom.Document) ConnectorEditor(com.twinsoft.convertigo.eclipse.editors.connector.ConnectorEditor) NoSuchElementException(java.util.NoSuchElementException)

Example 4 with Sequence

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

the class ReferencesView method getRequiredRequestables.

private void getRequiredRequestables(Step step, Project projectSelected, ProjectExplorerView projectExplorerView, AbstractParentNode parentNode, List<String> transactionList, List<String> sequenceList) {
    try {
        if (step instanceof SequenceStep) {
            SequenceStep sequenceStep = (SequenceStep) step;
            String sourceProjectName = sequenceStep.getProjectName();
            if (!sourceProjectName.equals(projectSelected.getName())) {
                Project project;
                project = getProject(sourceProjectName, projectExplorerView);
                ProjectNode projectNode = new ProjectNode(parentNode, sourceProjectName, project);
                Sequence sourceSequence = null;
                String sourceSequenceName = sequenceStep.getSequenceName();
                try {
                    if (project != null)
                        sourceSequence = project.getSequenceByName(sourceSequenceName);
                } catch (EngineException e) {
                    sourceSequence = null;
                }
                projectNode.addChild(new SequenceNode(projectNode, sourceSequenceName, sourceSequence));
                if (!sequenceList.contains(sourceProjectName + sourceSequenceName)) {
                    sequenceList.add(sourceProjectName + sourceSequenceName);
                    parentNode.addChild(projectNode);
                }
            }
        } else if (step instanceof TransactionStep) {
            TransactionStep transactionStep = (TransactionStep) step;
            String sourceProjectName = transactionStep.getProjectName();
            if (!sourceProjectName.equals(projectSelected.getName())) {
                Project project;
                project = getProject(sourceProjectName, projectExplorerView);
                ProjectNode projectNode = new ProjectNode(parentNode, sourceProjectName, project);
                if (project != null) {
                    Connector connector = project.getConnectorByName(transactionStep.getConnectorName());
                    ConnectorNode connectorNode = null;
                    connectorNode = getConnectorNode(projectNode, connector);
                    projectNode.addChild(connectorNode);
                    Transaction sourceTransaction = null;
                    String sourceTransactionName = transactionStep.getTransactionName();
                    try {
                        if (connector != null)
                            sourceTransaction = connector.getTransactionByName(sourceTransactionName);
                    } catch (Exception e) {
                        sourceTransaction = null;
                    }
                    connectorNode.addChild(new TransactionNode(connectorNode, sourceTransactionName, sourceTransaction));
                    if (!transactionList.contains(project.getName() + connector.getName() + sourceTransactionName)) {
                        transactionList.add(project.getName() + connector.getName() + sourceTransactionName);
                        parentNode.addChild(projectNode);
                    }
                }
            }
        } else if (isStepContainer(step)) {
            List<Step> steps = getStepList(step);
            if (steps != null) {
                for (Step s : steps) {
                    getRequiredRequestables(s, projectSelected, projectExplorerView, parentNode, transactionList, sequenceList);
                }
            }
        }
    } catch (EngineException e) {
        ConvertigoPlugin.logException(e, "Unable to load the project", true);
    }
}
Also used : HtmlConnector(com.twinsoft.convertigo.beans.connectors.HtmlConnector) JavelinConnector(com.twinsoft.convertigo.beans.connectors.JavelinConnector) HttpConnector(com.twinsoft.convertigo.beans.connectors.HttpConnector) ProxyHttpConnector(com.twinsoft.convertigo.beans.connectors.ProxyHttpConnector) Connector(com.twinsoft.convertigo.beans.core.Connector) CicsConnector(com.twinsoft.convertigo.beans.connectors.CicsConnector) SiteClipperConnector(com.twinsoft.convertigo.beans.connectors.SiteClipperConnector) SqlConnector(com.twinsoft.convertigo.beans.connectors.SqlConnector) SequenceStep(com.twinsoft.convertigo.beans.steps.SequenceStep) EngineException(com.twinsoft.convertigo.engine.EngineException) Sequence(com.twinsoft.convertigo.beans.core.Sequence) 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) SequenceNode(com.twinsoft.convertigo.eclipse.views.references.model.SequenceNode) 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) EngineException(com.twinsoft.convertigo.engine.EngineException) TransactionStep(com.twinsoft.convertigo.beans.steps.TransactionStep) 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) TransactionNode(com.twinsoft.convertigo.eclipse.views.references.model.TransactionNode) ProjectNode(com.twinsoft.convertigo.eclipse.views.references.model.ProjectNode)

Example 5 with Sequence

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

the class ReferencesView method handleProjectSelection.

private void handleProjectSelection(Object firstElement) {
    List<String> projectNames = Engine.theApp.databaseObjectsManager.getAllProjectNamesList();
    ProjectExplorerView projectExplorerView = ConvertigoPlugin.getDefault().getProjectExplorerView();
    Project projectSelected = null;
    ProjectTreeObject projectTreeObjectSelected = null;
    UnloadedProjectTreeObject unloadedProjectTreeObjectSelected = null;
    if (firstElement instanceof ProjectTreeObject) {
        projectTreeObjectSelected = (ProjectTreeObject) firstElement;
        projectSelected = projectTreeObjectSelected.getObject();
    } else if (firstElement instanceof UnloadedProjectTreeObject) {
        unloadedProjectTreeObjectSelected = (UnloadedProjectTreeObject) firstElement;
        String projectNameSelected = unloadedProjectTreeObjectSelected.getName();
        projectSelected = getProject(projectNameSelected, projectExplorerView);
    }
    if (projectSelected == null) {
        return;
    }
    String projectNameSelected = projectSelected.getName();
    treeViewer.setInput(null);
    // Get the referencing sequences and transactions
    List<Sequence> sequences = projectSelected.getSequencesList();
    RootNode root = new RootNode();
    ProjectNode projectNode = new ProjectNode(root, projectNameSelected, projectSelected);
    root.addChild(projectNode);
    // Get all the projects needed to successfully execute the selected project
    // i.e. get all CallTransaction and CallSequence steps from the selected project
    // that refer to other projects
    RequiresNode requiresNode = new RequiresNode(root, "Requires");
    // Search for external sequence or transaction referenced by CallSequence or CallTransaction
    // from the selected project
    List<String> transactionList = new ArrayList<String>();
    List<String> sequenceList = new ArrayList<String>();
    for (Sequence sequence : sequences) {
        List<Step> steps = sequence.getSteps();
        for (Step step : steps) {
            getRequiredRequestables(step, projectSelected, projectExplorerView, requiresNode, transactionList, sequenceList);
        }
    }
    UrlMapper urlMapper = projectSelected.getUrlMapper();
    if (urlMapper != null) {
        List<UrlMapping> mappings = urlMapper.getMappingList();
        for (UrlMapping mapping : mappings) {
            List<UrlMappingOperation> operations = mapping.getOperationList();
            for (UrlMappingOperation operation : operations) {
                try {
                    String targetRequestableName = operation.getTargetRequestable();
                    if (!targetRequestableName.isEmpty() && !targetRequestableName.startsWith(projectNameSelected)) {
                        handleTargetRequestable(targetRequestableName, projectExplorerView, requiresNode);
                    }
                } catch (Exception e) {
                    ConvertigoPlugin.logException(e, "Error while analyzing the projects hierarchy", true);
                }
            }
        }
    }
    if (requiresNode.hasChildren()) {
        projectNode.addChild(requiresNode);
    } else {
        projectNode.addChild(new InformationNode(projectNode, "This project does not require any other project"));
    }
    // Get all the projects using the selected project
    // i.e. get all CallTransaction and CallSequence steps that refer to transactions
    // or sequences from the selected project
    IsUsedByNode isUsedByNode = new IsUsedByNode(root, "Is used by");
    for (String projectName : projectNames) {
        if (!(projectName.equals(projectNameSelected))) {
            Project project = getProject(projectName, projectExplorerView);
            if (project == null) {
                // Unable to load the project, just ignore it
                ConvertigoPlugin.logWarning("[References View] Unable to load the project \"" + projectName + "\"", false);
                continue;
            }
            ProjectNode projectFolderExports = new ProjectNode(root, projectName, project);
            urlMapper = project.getUrlMapper();
            if (urlMapper != null) {
                MapperNode mapperNode = new MapperNode(projectFolderExports, 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(projectNameSelected + ".")) {
                            MappingOperationNode operationNode = new MappingOperationNode(pathNode, operation.getName(), operation);
                            pathNode.addChild(operationNode);
                        }
                    }
                    if (pathNode.hasChildren()) {
                        mapperNode.addChild(pathNode);
                    }
                }
                if (mapperNode.hasChildren()) {
                    projectFolderExports.addChild(mapperNode);
                }
            }
            List<Sequence> sequencesList = project.getSequencesList();
            for (Sequence sequence : sequencesList) {
                // Search for CallTransaction and CallSequence
                // referencing a transaction or sequence
                // from the selected project
                List<Step> stepList = sequence.getSteps();
                SequenceNode sequenceNode = new SequenceNode(root, sequence.getName(), sequence);
                for (Step step : stepList) {
                    getUsedRequestables(step, projectSelected, sequenceNode);
                }
                if (sequenceNode.hasChildren()) {
                    projectFolderExports.addChild(sequenceNode);
                }
            }
            if (projectFolderExports.hasChildren()) {
                isUsedByNode.addChild(projectFolderExports);
            }
        }
    }
    if (isUsedByNode.hasChildren()) {
        projectNode.addChild(isUsedByNode);
    } else {
        projectNode.addChild(new InformationNode(projectNode, "This project is not used by any other project"));
    }
    treeViewer.setInput(null);
    treeViewer.setInput(root);
    treeViewer.expandAll();
}
Also used : UrlMapping(com.twinsoft.convertigo.beans.core.UrlMapping) RootNode(com.twinsoft.convertigo.eclipse.views.references.model.RootNode) MapperNode(com.twinsoft.convertigo.eclipse.views.references.model.MapperNode) ArrayList(java.util.ArrayList) 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) InformationNode(com.twinsoft.convertigo.eclipse.views.references.model.InformationNode) UrlMapper(com.twinsoft.convertigo.beans.core.UrlMapper) ProjectExplorerView(com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView) UrlMappingOperation(com.twinsoft.convertigo.beans.core.UrlMappingOperation) Sequence(com.twinsoft.convertigo.beans.core.Sequence) MappingOperationNode(com.twinsoft.convertigo.eclipse.views.references.model.MappingOperationNode) EngineException(com.twinsoft.convertigo.engine.EngineException) SequenceNode(com.twinsoft.convertigo.eclipse.views.references.model.SequenceNode) Project(com.twinsoft.convertigo.beans.core.Project) UnloadedProjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UnloadedProjectTreeObject) MappingPathNode(com.twinsoft.convertigo.eclipse.views.references.model.MappingPathNode) RequiresNode(com.twinsoft.convertigo.eclipse.views.references.model.RequiresNode) IsUsedByNode(com.twinsoft.convertigo.eclipse.views.references.model.IsUsedByNode) ProjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ProjectTreeObject) UnloadedProjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UnloadedProjectTreeObject) ProjectNode(com.twinsoft.convertigo.eclipse.views.references.model.ProjectNode)

Aggregations

Sequence (com.twinsoft.convertigo.beans.core.Sequence)93 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)47 EngineException (com.twinsoft.convertigo.engine.EngineException)42 Step (com.twinsoft.convertigo.beans.core.Step)38 TreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject)36 Project (com.twinsoft.convertigo.beans.core.Project)34 ProjectExplorerView (com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView)33 DatabaseObjectTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject)32 Transaction (com.twinsoft.convertigo.beans.core.Transaction)29 Cursor (org.eclipse.swt.graphics.Cursor)28 Display (org.eclipse.swt.widgets.Display)28 Shell (org.eclipse.swt.widgets.Shell)28 StepWithExpressions (com.twinsoft.convertigo.beans.core.StepWithExpressions)27 Connector (com.twinsoft.convertigo.beans.core.Connector)21 StepTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.StepTreeObject)20 ThenStep (com.twinsoft.convertigo.beans.steps.ThenStep)19 TransactionStep (com.twinsoft.convertigo.beans.steps.TransactionStep)18 SequenceStep (com.twinsoft.convertigo.beans.steps.SequenceStep)17 TreeParent (com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeParent)17 RequestableStep (com.twinsoft.convertigo.beans.core.RequestableStep)16