Search in sources :

Example 11 with NodeContainer

use of org.talend.designer.core.ui.editor.nodecontainer.NodeContainer in project tesb-studio-se by Talend.

the class CreateNewJobAction method createNewProcess.

private boolean createNewProcess(RepositoryNode nodeOperation, final ProcessItem process) {
    if (process == null) {
        return false;
    }
    try {
        // Set readonly to false since created job will always be editable.
        ProcessEditorInput fileEditorInput = new ProcessEditorInput(process, false, true, false);
        IRepositoryNode repositoryNode = RepositorySeekerManager.getInstance().searchRepoViewNode(fileEditorInput.getItem().getProperty().getId());
        fileEditorInput.setRepositoryNode(repositoryNode);
        IEditorPart openEditor = getActivePage().openEditor(fileEditorInput, MultiPageTalendEditor.ID, true);
        CommandStack commandStack = (CommandStack) openEditor.getAdapter(CommandStack.class);
        final Node nodeProviderRequest = new Node(ComponentsFactoryProvider.getInstance().get(T_ESB_PROVIDER_REQUEST, ComponentCategory.CATEGORY_4_DI.getName()), fileEditorInput.getLoadedProcess());
        final RepositoryNode portNode = nodeOperation.getParent();
        ServiceItem serviceItem = (ServiceItem) portNode.getParent().getObject().getProperty().getItem();
        IFile wsdlPath = WSDLUtils.getWsdlFile(serviceItem);
        Map<String, String> serviceParameters = WSDLUtils.getServiceOperationParameters(wsdlPath, ((OperationRepositoryObject) nodeOperation.getObject()).getName(), portNode.getObject().getLabel());
        setProviderRequestComponentConfiguration(nodeProviderRequest, serviceParameters);
        CreateNodeContainerCommand cNcc = new CreateNodeContainerCommand(fileEditorInput.getLoadedProcess(), new NodeContainer(nodeProviderRequest), new Point(3 * Node.DEFAULT_SIZE, 4 * Node.DEFAULT_SIZE));
        commandStack.execute(cNcc);
        if (!WSDLUtils.ONE_WAY.equals(serviceParameters.get(WSDLUtils.COMMUNICATION_STYLE))) {
            Node node = new Node(ComponentsFactoryProvider.getInstance().get(T_ESB_PROVIDER_RESPONSE, ComponentCategory.CATEGORY_4_DI.getName()), fileEditorInput.getLoadedProcess());
            cNcc = new CreateNodeContainerCommand(fileEditorInput.getLoadedProcess(), new NodeContainer(node), new Point(9 * Node.DEFAULT_SIZE, 4 * Node.DEFAULT_SIZE));
            commandStack.execute(cNcc);
        }
        String faults = serviceParameters.get(WSDLUtils.FAULTS);
        if (null != faults) {
            int horMultiplier = 15;
            for (String fault : faults.split(",")) {
                Node node = new Node(ComponentsFactoryProvider.getInstance().get(T_ESB_PROVIDER_FAULT, ComponentCategory.CATEGORY_4_DI.getName()), fileEditorInput.getLoadedProcess());
                cNcc = new CreateNodeContainerCommand(fileEditorInput.getLoadedProcess(), new NodeContainer(node), new Point(horMultiplier * Node.DEFAULT_SIZE, 4 * Node.DEFAULT_SIZE));
                commandStack.execute(cNcc);
                //$NON-NLS-1$
                node.getElementParameter("ESB_FAULT_TITLE").setValue('\"' + fault + '\"');
                horMultiplier += 6;
            }
        }
        ServiceConnection serviceConnection = (ServiceConnection) serviceItem.getConnection();
        final String parentPortName = portNode.getObject().getLabel();
        for (ServicePort port : serviceConnection.getServicePort()) {
            if (port.getName().equals(parentPortName)) {
                for (ServiceOperation operation : port.getServiceOperation()) {
                    if (operation.getLabel().equals(nodeOperation.getObject().getLabel())) {
                        String jobName = process.getProperty().getLabel();
                        String jobID = process.getProperty().getId();
                        operation.setReferenceJobId(jobID);
                        operation.setLabel(operation.getName() + "-" + jobName);
                        break;
                    }
                }
                break;
            }
        }
        repositoryChange(nodeOperation, nodeProviderRequest);
        ProxyRepositoryFactory.getInstance().save(serviceItem);
        return true;
    } catch (PartInitException e) {
        ExceptionHandler.process(e);
    } catch (PersistenceException e) {
        MessageBoxExceptionHandler.process(e);
    } catch (Exception e) {
        ExceptionHandler.process(e);
    }
    return false;
}
Also used : CommandStack(org.eclipse.gef.commands.CommandStack) ServicePort(org.talend.repository.services.model.services.ServicePort) ServiceConnection(org.talend.repository.services.model.services.ServiceConnection) IFile(org.eclipse.core.resources.IFile) IRepositoryNode(org.talend.repository.model.IRepositoryNode) Node(org.talend.designer.core.ui.editor.nodes.Node) INode(org.talend.core.model.process.INode) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) IEditorPart(org.eclipse.ui.IEditorPart) Point(org.eclipse.draw2d.geometry.Point) ServiceOperation(org.talend.repository.services.model.services.ServiceOperation) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) Point(org.eclipse.draw2d.geometry.Point) PartInitException(org.eclipse.ui.PartInitException) PersistenceException(org.talend.commons.exception.PersistenceException) ProcessEditorInput(org.talend.designer.core.ui.editor.ProcessEditorInput) CreateNodeContainerCommand(org.talend.designer.core.ui.editor.cmd.CreateNodeContainerCommand) PersistenceException(org.talend.commons.exception.PersistenceException) ServiceItem(org.talend.repository.services.model.services.ServiceItem) PartInitException(org.eclipse.ui.PartInitException)

Example 12 with NodeContainer

use of org.talend.designer.core.ui.editor.nodecontainer.NodeContainer in project tesb-studio-se by Talend.

the class LocalESBRunContainerServiceTest method testCreateJavaProcessor.

/**
     * Test method for
     * {@link org.talend.designer.esb.runcontainer.core.LocalESBRunContainerService#createJavaProcessor(org.talend.core.model.process.IProcess, Property, boolean)}
     */
@Test
public void testCreateJavaProcessor() {
    IESBRunContainerService service = (IESBRunContainerService) GlobalServiceRegister.getDefault().getService(IESBRunContainerService.class);
    String[] esbComponents = { "tESBProviderRequest", "tRESTClient", "tRESTRequest", "tRESTResponse", "tESBConsumer", "tESBProviderFault", "tESBProviderRequest", "tESBProviderResponse" };
    for (String esbComponent : esbComponents) {
        Property property = PropertiesFactory.eINSTANCE.createProperty();
        property.setVersion("0.1");
        property.setId("property1");
        property.setLabel("ESBArtifact");
        ProcessItem processItem = PropertiesFactory.eINSTANCE.createProcessItem();
        processItem.setProperty(property);
        property.setItem(processItem);
        ProcessType process = TalendFileFactory.eINSTANCE.createProcessType();
        processItem.setProcess(process);
        NodeType node = TalendFileFactory.eINSTANCE.createNodeType();
        process.getNode().add(node);
        node.setComponentName(esbComponent);
        IComponent tESBComponent = ComponentsFactoryProvider.getInstance().get(esbComponent, ComponentCategory.CATEGORY_4_DI.getName());
        Process esbJob = new Process(property);
        Node tESBComponent_1 = new Node(tESBComponent, esbJob);
        esbJob.addNodeContainer(new NodeContainer(tESBComponent_1));
        Assert.assertNotNull(service.createJavaProcessor(esbJob, property, false));
    }
}
Also used : ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) IESBRunContainerService(org.talend.designer.runprocess.IESBRunContainerService) ProcessItem(org.talend.core.model.properties.ProcessItem) IComponent(org.talend.core.model.components.IComponent) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) Node(org.talend.designer.core.ui.editor.nodes.Node) Process(org.talend.designer.core.ui.editor.process.Process) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) Property(org.talend.core.model.properties.Property) Test(org.junit.Test)

Example 13 with NodeContainer

use of org.talend.designer.core.ui.editor.nodecontainer.NodeContainer in project tdi-studio-se by Talend.

the class ProcessErrorUtilTest method testGetAllErrorMess.

/**
     * Test method for
     * {@link org.talend.designer.runprocess.ui.ProcessComposite#getAllErrorMess(org.talend.designer.runprocess.IProcessMessage)}
     * .
     */
@Test
public void testGetAllErrorMess() {
    Property property1 = PropertiesFactory.eINSTANCE.createProperty();
    //$NON-NLS-1$
    property1.setId("property1");
    //$NON-NLS-1$
    property1.setVersion("0.1");
    //$NON-NLS-1$
    property1.setLabel("ParentJob");
    Process process = new Process(property1);
    IComponent tOracleSPComponent = ComponentsFactoryProvider.getInstance().get("tOracleSP", ComponentCategory.CATEGORY_4_DI.getName());
    Node tOracleSP_1 = new Node(tOracleSPComponent, process);
    process.addNodeContainer(new NodeContainer(tOracleSP_1));
    RunProcessContext context = new RunProcessContext(process);
    String errorMessage1 = "Exception in component tOracleSP_1 (ParentJob)\njava.sql.SQLException: ORA-20000: Failed to execute one or more sql statements";
    ProcessMessage message1 = new ProcessMessage(MsgType.STD_ERR, errorMessage1);
    HashMap<String, IProcessMessage> errorMessMap = ProcessErrorUtil.getAllErrorMess(message1, context);
    Assert.assertEquals(errorMessMap.get(tOracleSP_1.getUniqueName()).getContent(), errorMessage1);
    String errorMessage2 = "Exception in component tOracleSP_1 (ChildJob)\njava.sql.SQLException: ORA-20000: Failed to execute one or more sql statements";
    ProcessMessage message2 = new ProcessMessage(MsgType.STD_ERR, errorMessage2);
    HashMap<String, IProcessMessage> errorMessMap2 = ProcessErrorUtil.getAllErrorMess(message2, context);
    Assert.assertNull(errorMessMap2.get(tOracleSP_1.getUniqueName()));
}
Also used : RunProcessContext(org.talend.designer.runprocess.RunProcessContext) IProcessMessage(org.talend.designer.runprocess.IProcessMessage) IComponent(org.talend.core.model.components.IComponent) Node(org.talend.designer.core.ui.editor.nodes.Node) IProcessMessage(org.talend.designer.runprocess.IProcessMessage) ProcessMessage(org.talend.designer.runprocess.ProcessMessage) Process(org.talend.designer.core.ui.editor.process.Process) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) Property(org.talend.core.model.properties.Property) Test(org.junit.Test)

Example 14 with NodeContainer

use of org.talend.designer.core.ui.editor.nodecontainer.NodeContainer in project tdi-studio-se by Talend.

the class JavaProcessorUtilitiesTest method testComputeLibrariesPathWithMissingJars.

@Test
public void testComputeLibrariesPathWithMissingJars() {
    boolean headless = CommonsPlugin.isHeadless();
    try {
        // don't popup dialog to block ui
        CommonsPlugin.setHeadless(true);
        IComponent tLibraryLoadComponent = ComponentsFactoryProvider.getInstance().get("tLibraryLoad", ComponentCategory.CATEGORY_4_DI.getName());
        Property property = PropertiesFactory.eINSTANCE.createProperty();
        //$NON-NLS-1$
        property.setId("property");
        //$NON-NLS-1$
        property.setVersion("0.1");
        //$NON-NLS-1$
        property.setLabel("test");
        Process process = new Process(property);
        Node tLibraryLoad_1 = new Node(tLibraryLoadComponent, process);
        process.addNodeContainer(new NodeContainer(tLibraryLoad_1));
        tLibraryLoad_1.getElementParameter("LIBRARY").setValue("computeLibrariesPath.jar");
        Set<ModuleNeeded> neededLibraries = CorePlugin.getDefault().getDesignerCoreService().getNeededLibrariesForProcess(process, false);
        ProcessorException exception = null;
        try {
            JavaProcessorUtilities.computeLibrariesPath(neededLibraries, process, new HashSet<ModuleNeeded>());
        } catch (ProcessorException e) {
            exception = e;
        }
        if (exception != null) {
            Assert.assertTrue(exception.getMessage().contains("computeLibrariesPath.jar"));
        } else {
            fail("computeLibrariesPath failed for process test{tLibraryLoad},computeLibrariesPath.jar not found but no exception");
        }
    } finally {
        CommonsPlugin.setHeadless(headless);
    }
}
Also used : ProcessorException(org.talend.designer.runprocess.ProcessorException) IComponent(org.talend.core.model.components.IComponent) Node(org.talend.designer.core.ui.editor.nodes.Node) Process(org.talend.designer.core.ui.editor.process.Process) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) Property(org.talend.core.model.properties.Property) ModuleNeeded(org.talend.core.model.general.ModuleNeeded) Test(org.junit.Test)

Example 15 with NodeContainer

use of org.talend.designer.core.ui.editor.nodecontainer.NodeContainer in project tdi-studio-se by Talend.

the class JavaProcessorUtilitiesTest method testComputeLibrariesPath.

@Test
public void testComputeLibrariesPath() {
    boolean headless = CommonsPlugin.isHeadless();
    try {
        CommonsPlugin.setHeadless(true);
        IComponent tFixedFlowComponent = ComponentsFactoryProvider.getInstance().get("tFixedFlowInput", ComponentCategory.CATEGORY_4_DI.getName());
        IComponent tLogRowComponent = ComponentsFactoryProvider.getInstance().get("tLogRow", ComponentCategory.CATEGORY_4_DI.getName());
        Property property = PropertiesFactory.eINSTANCE.createProperty();
        //$NON-NLS-1$
        property.setId("property");
        //$NON-NLS-1$
        property.setVersion("0.1");
        //$NON-NLS-1$
        property.setLabel("test");
        Process process = new Process(property);
        Node tFixedFlowInput_1 = new Node(tFixedFlowComponent, process);
        createMetadataColumns(tFixedFlowInput_1.getMetadataList().get(0), 1);
        Node tLogRow_1 = new Node(tLogRowComponent, process);
        createMetadataColumns(tLogRow_1.getMetadataList().get(0), 1);
        process.addNodeContainer(new NodeContainer(tFixedFlowInput_1));
        process.addNodeContainer(new NodeContainer(tLogRow_1));
        new Connection(tFixedFlowInput_1, tLogRow_1, EConnectionType.FLOW_MAIN, EConnectionType.FLOW_MAIN.getName(), "tFixedFlowInput_1", "row1", "row1", false);
        Set<ModuleNeeded> neededLibraries = CorePlugin.getDefault().getDesignerCoreService().getNeededLibrariesForProcess(process, false);
        try {
            JavaProcessorUtilities.computeLibrariesPath(neededLibraries, process, new HashSet<ModuleNeeded>());
        } catch (ProcessorException e) {
            fail("computeLibrariesPath failed for process test{tFixedFlowInput->tLogRow}");
        }
    } finally {
        CommonsPlugin.setHeadless(headless);
    }
}
Also used : ProcessorException(org.talend.designer.runprocess.ProcessorException) IComponent(org.talend.core.model.components.IComponent) Node(org.talend.designer.core.ui.editor.nodes.Node) Connection(org.talend.designer.core.ui.editor.connections.Connection) Process(org.talend.designer.core.ui.editor.process.Process) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) Property(org.talend.core.model.properties.Property) ModuleNeeded(org.talend.core.model.general.ModuleNeeded) Test(org.junit.Test)

Aggregations

NodeContainer (org.talend.designer.core.ui.editor.nodecontainer.NodeContainer)60 Node (org.talend.designer.core.ui.editor.nodes.Node)43 ArrayList (java.util.ArrayList)23 INode (org.talend.core.model.process.INode)23 List (java.util.List)20 Process (org.talend.designer.core.ui.editor.process.Process)20 Point (org.eclipse.draw2d.geometry.Point)17 IComponent (org.talend.core.model.components.IComponent)13 IConnection (org.talend.core.model.process.IConnection)12 SubjobContainerPart (org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart)12 Rectangle (org.eclipse.draw2d.geometry.Rectangle)11 IProcess (org.talend.core.model.process.IProcess)11 Connection (org.talend.designer.core.ui.editor.connections.Connection)11 IElementParameter (org.talend.core.model.process.IElementParameter)10 EditPart (org.eclipse.gef.EditPart)9 IExternalNode (org.talend.core.model.process.IExternalNode)9 IGraphicalNode (org.talend.core.ui.process.IGraphicalNode)9 CreateNodeContainerCommand (org.talend.designer.core.ui.editor.cmd.CreateNodeContainerCommand)9 NodePart (org.talend.designer.core.ui.editor.nodes.NodePart)9 HashMap (java.util.HashMap)8