Search in sources :

Example 26 with IProcess

use of org.talend.core.model.process.IProcess in project tesb-studio-se by Talend.

the class ESBService method refreshComponentView.

/**
     * When services connection is renamed, refresh the connection label in the component view of job.
     * 
     * @param item
     */
@Override
public void refreshComponentView(Item item) {
    try {
        IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
        IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
        IEditorReference[] editors = activePage.getEditorReferences();
        for (IEditorReference er : editors) {
            IEditorPart part = er.getEditor(false);
            if (part instanceof AbstractMultiPageTalendEditor) {
                AbstractMultiPageTalendEditor editor = (AbstractMultiPageTalendEditor) part;
                CommandStack stack = (CommandStack) editor.getTalendEditor().getAdapter(CommandStack.class);
                if (stack != null) {
                    IProcess process = editor.getProcess();
                    for (final INode processNode : process.getGraphicalNodes()) {
                        if (processNode instanceof Node) {
                            checkRepository((Node) processNode, item, stack);
                        }
                    }
                }
            }
        }
    } catch (Exception e) {
        ExceptionHandler.process(e);
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) CommandStack(org.eclipse.gef.commands.CommandStack) INode(org.talend.core.model.process.INode) IEditorReference(org.eclipse.ui.IEditorReference) AbstractMultiPageTalendEditor(org.talend.designer.core.ui.AbstractMultiPageTalendEditor) ProjectRepositoryNode(org.talend.core.repository.model.ProjectRepositoryNode) 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) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IEditorPart(org.eclipse.ui.IEditorPart) IProcess(org.talend.core.model.process.IProcess) CoreException(org.eclipse.core.runtime.CoreException) BusinessException(org.talend.commons.exception.BusinessException) IOException(java.io.IOException) PersistenceException(org.talend.commons.exception.PersistenceException)

Example 27 with IProcess

use of org.talend.core.model.process.IProcess in project tesb-studio-se by Talend.

the class AssignJobAction method assign.

public boolean assign(IRepositoryNode jobNode) {
    if (jobNode == null) {
        return false;
    }
    IRepositoryViewObject repositoryObject = jobNode.getObject();
    final Item item = repositoryObject.getProperty().getItem();
    // judge the job whether had T_ESB_PROVIDER_REQUEST
    ProcessItem processItem = (ProcessItem) item;
    NodeType providerNode = null;
    for (Object obj : processItem.getProcess().getNode()) {
        NodeType node = (NodeType) obj;
        if (CreateNewJobAction.T_ESB_PROVIDER_REQUEST.equals(node.getComponentName())) {
            providerNode = node;
            break;
        }
    }
    if (null == providerNode) {
        MessageDialog.openWarning(Display.getCurrent().getActiveShell(), Messages.AssignJobAction_WarningTitle, Messages.AssignJobAction_WarningMessage);
        return false;
    }
    try {
        String jobID = item.getProperty().getId();
        String jobName = item.getProperty().getLabel();
        String operationName = repositoryNode.getObject().getLabel();
        String portName = repositoryNode.getParent().getObject().getLabel();
        ServiceItem serviceItem = (ServiceItem) repositoryNode.getParent().getParent().getObject().getProperty().getItem();
        List<ServicePort> listPort = ((ServiceConnection) serviceItem.getConnection()).getServicePort();
        for (ServicePort port : listPort) {
            if (port.getName().equals(portName)) {
                List<ServiceOperation> listOperation = port.getServiceOperation();
                for (ServiceOperation operation : listOperation) {
                    if (operation.getLabel().equals(operationName)) {
                        // should not change the job name
                        // String jobNewName = port.getName() + "_" + operation.getName();
                        // if (resetJobname(item, jobNewName)) {
                        // jobName = jobNewName;
                        // }
                        operation.setReferenceJobId(jobID);
                        operation.setLabel(operation.getName() + "-" + jobName);
                        break;
                    }
                }
                break;
            }
        }
        IFile wsdlPath = WSDLUtils.getWsdlFile(serviceItem);
        Map<String, String> serviceParameters = WSDLUtils.getServiceOperationParameters(wsdlPath, ((OperationRepositoryObject) repositoryNode.getObject()).getName(), portName);
        for (Object paramObj : providerNode.getElementParameter()) {
            ElementParameterType param = (ElementParameterType) paramObj;
            String name = param.getName();
            if (serviceParameters.containsKey(name)) {
                param.setValue(serviceParameters.get(name));
            }
        }
        IProcess2 process = null;
        IEditorReference[] reference = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences();
        List<IProcess2> processes = RepositoryPlugin.getDefault().getDesignerCoreService().getOpenedProcess(reference);
        for (IProcess2 processOpen : processes) {
            if (processOpen.getProperty().getItem() == processItem) {
                process = processOpen;
                break;
            }
        }
        if (process == null) {
            IDesignerCoreService service = CorePlugin.getDefault().getDesignerCoreService();
            IProcess proc = service.getProcessFromProcessItem(processItem);
            if (proc instanceof IProcess2) {
                process = (IProcess2) proc;
            }
        }
        if (process != null) {
            List<? extends INode> nodelist = process.getGraphicalNodes();
            for (INode node : nodelist) {
                if (node.getComponent().getName().equals("tESBProviderRequest")) {
                    repositoryChange(repositoryNode, node);
                }
            }
            processItem.setProcess(process.saveXmlFile());
        }
        IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
        factory.save(processItem);
        factory.save(serviceItem);
        return true;
    } catch (Exception e) {
        ExceptionHandler.process(e);
    }
    return false;
}
Also used : ServicePort(org.talend.repository.services.model.services.ServicePort) ServiceConnection(org.talend.repository.services.model.services.ServiceConnection) INode(org.talend.core.model.process.INode) IFile(org.eclipse.core.resources.IFile) ServiceOperation(org.talend.repository.services.model.services.ServiceOperation) Item(org.talend.core.model.properties.Item) ConnectionItem(org.talend.core.model.properties.ConnectionItem) ServiceItem(org.talend.repository.services.model.services.ServiceItem) ProcessItem(org.talend.core.model.properties.ProcessItem) IEditorReference(org.eclipse.ui.IEditorReference) IDesignerCoreService(org.talend.designer.core.IDesignerCoreService) IProcess(org.talend.core.model.process.IProcess) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) IOException(java.io.IOException) PersistenceException(org.talend.commons.exception.PersistenceException) ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) ProcessItem(org.talend.core.model.properties.ProcessItem) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IProcess2(org.talend.core.model.process.IProcess2) PortRepositoryObject(org.talend.repository.services.utils.PortRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) OperationRepositoryObject(org.talend.repository.services.utils.OperationRepositoryObject) ServiceItem(org.talend.repository.services.model.services.ServiceItem)

Example 28 with IProcess

use of org.talend.core.model.process.IProcess in project tesb-studio-se by Talend.

the class ESBService method changeOtherJobSchemaValue.

// private void changenewOperationLabel(RepositoryNode newNode, INode node, ServiceConnection serConn) {
// String operationName = newNode.getObject().getLabel();
// String parentPortName = newNode.getParent().getObject().getLabel();
//
// String wsdlPath = serConn.getWSDLPath();
// try {
// Map<String, String> serviceParameters = WSDLUtils.getServiceParameters(wsdlPath);
// IRepositoryViewObject newObj = newNode.getObject();
// if (newObj instanceof OperationRepositoryObject) {
// ServiceOperation newOpe = (ServiceOperation) ((OperationRepositoryObject) newObj).getAbstractMetadataObject();
//
// IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
//
// if (newOpe.getReferenceJobId() != null) {
// changeOtherJobSchemaValue(factory, newOpe, serConn);
// MessageDialog.openWarning(new Shell(), "warning",
// "This other job which based on the Operation will be unset!");
// }
//
// IEditorPart activeEditor =
// PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
// IEditorInput input = activeEditor.getEditorInput();
// if (input instanceof ProcessEditorInput) {
// Item jobItem = ((ProcessEditorInput) input).getItem();
// String jobID = jobItem.getProperty().getId();
// String jobName = jobItem.getProperty().getLabel();
//
// newOpe.setReferenceJobId(jobID);
// newOpe.setLabel(newOpe.getName() + "-" + jobName);
//
// serviceParameters.put(WSDLUtils.PORT_NAME, parentPortName);
// serviceParameters.put(WSDLUtils.OPERATION_NAME, operationName);
//
// CreateNewJobAction.setProviderRequestComponentConfiguration(node, serviceParameters);
//
// try {
// factory.save(jobItem);
// } catch (PersistenceException e) {
// e.printStackTrace();
// }
// try {
// factory.save(newNode.getParent().getParent().getObject().getProperty().getItem());
// } catch (PersistenceException e) {
// e.printStackTrace();
// }
// RepositoryManager.refreshSavedNode(newNode);
// }
// }
//
// } catch (CoreException e1) {
// ExceptionHandler.process(e1);
// } catch (PersistenceException e) {
// ExceptionHandler.process(e);
// }
// }
private void changeOtherJobSchemaValue(IProxyRepositoryFactory factory, ServiceOperation newOpe, /*
                                                                                                      * ServiceConnection
                                                                                                      * serConn,
                                                                                                      */
RepositoryNode selectNode) throws PersistenceException, CoreException {
    IRepositoryViewObject jobObj = factory.getLastVersion(newOpe.getReferenceJobId());
    if (jobObj == null) {
        return;
    }
    ProcessItem processItem = (ProcessItem) jobObj.getProperty().getItem();
    IDesignerCoreService service = CorePlugin.getDefault().getDesignerCoreService();
    boolean foundInOpen = false;
    IProcess2 process = null;
    IEditorReference[] reference = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences();
    List<IProcess2> processes = RepositoryPlugin.getDefault().getDesignerCoreService().getOpenedProcess(reference);
    for (IProcess2 processOpen : processes) {
        if (processOpen.getProperty().getItem() == processItem) {
            foundInOpen = true;
            process = processOpen;
            break;
        }
    }
    if (!foundInOpen) {
        IProcess proc = service.getProcessFromProcessItem(processItem);
        if (proc instanceof IProcess2) {
            process = (IProcess2) proc;
        }
    }
    newOpe.setReferenceJobId(null);
    newOpe.setLabel(newOpe.getName());
    if (process != null) {
        List<? extends INode> nodelist = process.getGraphicalNodes();
        for (INode node : nodelist) {
            if (node.getComponent().getName().equals("tESBProviderRequest")) {
                repositoryChange(selectNode, node, process);
                break;
            }
        }
        try {
            if (!foundInOpen) {
                processItem.setProcess(process.saveXmlFile());
                factory.save(processItem);
            }
        } catch (PersistenceException e) {
            ExceptionHandler.process(e);
        } catch (IOException e) {
            ExceptionHandler.process(e);
        }
    }
// ProcessType process = item.getProcess();
// EList<NodeType> nodeList = process.getNode();
//
// for (NodeType node : nodeList) {
// EList parameters = node.getElementParameter();
// for (Object paramObj : parameters) {
// ElementParameterType param = (ElementParameterType) paramObj;
// String name = param.getName();
// if (name.equals(WSDLUtils.OPERATION_NAME)) {
// if (!newOpe.getName().equals(param.getValue())) {
// break;
// }
// param.setValue(null);
// }
// if (name.equals("SCHEMA:SCHEMA_TYPE")) {
// param.setValue("BUILT_IN");
// break;
// }
//
// }
//
// }
// factory.save(item);
}
Also used : INode(org.talend.core.model.process.INode) IOException(java.io.IOException) IEditorReference(org.eclipse.ui.IEditorReference) ProcessItem(org.talend.core.model.properties.ProcessItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IProcess2(org.talend.core.model.process.IProcess2) PersistenceException(org.talend.commons.exception.PersistenceException) IDesignerCoreService(org.talend.designer.core.IDesignerCoreService) IProcess(org.talend.core.model.process.IProcess)

Example 29 with IProcess

use of org.talend.core.model.process.IProcess in project tdi-studio-se by Talend.

the class ShadowProcess method runWithErrorOutputAsException.

/**
     * 
     * DOC xye Comment method "runWithErrorOutputAsException".
     * 
     * @param outputErrorAsException
     * @return
     * @throws ProcessorException
     */
public CsvArray runWithErrorOutputAsException(final boolean outputErrorAsException) throws ProcessorException {
    IProcess talendProcess = buildProcess();
    IProcessor processor = ProcessorUtilities.getProcessor(talendProcess, null);
    processor.setProxyParameters(getProxyParameters());
    File previousFile = outPath.toFile();
    if (previousFile.exists()) {
        previousFile.delete();
    }
    IContext context = talendProcess.getContextManager().getDefaultContext();
    processor.setContext(context);
    process = processor.run(IProcessor.NO_STATISTICS, IProcessor.NO_TRACES, null);
    String error = ProcessStreamTrashReader.readErrorStream(process);
    if (error != null) {
        log.warn(error, new ProcessorException(error));
    }
    if (!outPath.toFile().exists()) {
        if (outputErrorAsException && error != null) {
            throw new ProcessorException(error);
        } else {
            //$NON-NLS-1$
            throw new ProcessorException(Messages.getString("ShadowProcess.notGeneratedOutputException"));
        }
    }
    try {
        CsvArray array = new CsvArray();
        array = array.createFrom(outPath.toFile(), currentProcessEncoding);
        return array;
    } catch (IOException ioe) {
        throw new ProcessorException(ioe);
    }
}
Also used : IContext(org.talend.core.model.process.IContext) ProcessorException(org.talend.designer.runprocess.ProcessorException) CsvArray(org.talend.core.utils.CsvArray) IProcessor(org.talend.designer.runprocess.IProcessor) IOException(java.io.IOException) IProcess(org.talend.core.model.process.IProcess) File(java.io.File)

Example 30 with IProcess

use of org.talend.core.model.process.IProcess in project tdi-studio-se by Talend.

the class ActiveProcessTracker method partClosed.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.ui.IPartListener#partClosed(org.eclipse.ui.IWorkbenchPart)
     */
@Override
public void partClosed(IWorkbenchPart part) {
    if (part instanceof AbstractMultiPageTalendEditor && currentProcess != null) {
        AbstractMultiPageTalendEditor mpte = (AbstractMultiPageTalendEditor) part;
        if (mpte.isKeepPropertyLocked()) {
            currentProcess = null;
            return;
        }
        IProcess process = getJobFromActivatedEditor(part);
        if (process != null) {
            Problems.removeProblemsByProcess(process);
            Problems.removeJob(process);
            IRunProcessService service = DesignerPlugin.getDefault().getRunProcessService();
            service.removeProcess(process);
            CodeView.refreshCodeView(null);
            if (currentProcess == process) {
                //$NON-NLS-1$
                Contexts.setTitle("");
                Contexts.clearAll();
                if (lastProcessOpened == currentProcess) {
                    lastProcessOpened = null;
                }
                currentProcess = null;
                for (IJobTrackerListener listener : jobTrackerListeners) {
                    listener.allJobClosed();
                }
            } else if (lastProcessOpened == process) {
                lastProcessOpened = currentProcess;
            }
            if (GlobalServiceRegister.getDefault().isServiceRegistered(ISQLBuilderService.class)) {
                ISQLBuilderService sqlBuilderService = (ISQLBuilderService) GlobalServiceRegister.getDefault().getService(ISQLBuilderService.class);
                sqlBuilderService.closeSqlBuilderDialogs(process.getName());
            }
        }
    } else if (part instanceof IEditorPart) {
        if (GlobalServiceRegister.getDefault().isServiceRegistered(IDiagramModelService.class) && CorePlugin.getDefault().getDiagramModelService().isBusinessDiagramEditor((IEditorPart) part)) {
            //$NON-NLS-1$
            Contexts.setTitle("");
            Contexts.clearAll();
        }
    }
    if (part instanceof AbstractMultiPageTalendEditor) {
        AbstractMultiPageTalendEditor mpte = (AbstractMultiPageTalendEditor) part;
        mpte.beforeDispose();
        JobSettings.switchToCurJobSettingsView();
    }
}
Also used : IRunProcessService(org.talend.designer.runprocess.IRunProcessService) IEditorPart(org.eclipse.ui.IEditorPart) IProcess(org.talend.core.model.process.IProcess) ISQLBuilderService(org.talend.core.ui.services.ISQLBuilderService)

Aggregations

IProcess (org.talend.core.model.process.IProcess)102 INode (org.talend.core.model.process.INode)33 ArrayList (java.util.ArrayList)28 IDesignerCoreService (org.talend.designer.core.IDesignerCoreService)24 IProcess2 (org.talend.core.model.process.IProcess2)22 ProcessItem (org.talend.core.model.properties.ProcessItem)21 Node (org.talend.designer.core.ui.editor.nodes.Node)20 List (java.util.List)17 Item (org.talend.core.model.properties.Item)16 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)16 IOException (java.io.IOException)15 PersistenceException (org.talend.commons.exception.PersistenceException)14 IElementParameter (org.talend.core.model.process.IElementParameter)14 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)13 IEditorPart (org.eclipse.ui.IEditorPart)11 ProcessorException (org.talend.designer.runprocess.ProcessorException)10 File (java.io.File)9 Element (org.talend.core.model.process.Element)9 IConnection (org.talend.core.model.process.IConnection)9 IContext (org.talend.core.model.process.IContext)9