Search in sources :

Example 76 with IProcess

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

the class DesignerCoreService method getProcessFromItemByExtendion.

public IProcess getProcessFromItemByExtendion(Item item, boolean loadScreenshots) {
    IProcess process = null;
    List<IProcessConvertService> processConvertServices = ProcessConvertManager.getInstance().extractAllConvertServices();
    for (IProcessConvertService service : processConvertServices) {
        process = service.getProcessFromItem(item, loadScreenshots);
        if (process != null) {
            break;
        }
    }
    return process;
}
Also used : IProcessConvertService(org.talend.designer.core.convert.IProcessConvertService) IProcess(org.talend.core.model.process.IProcess)

Example 77 with IProcess

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

the class JobLaunchConfigurationDelegate method findProcessFromRepository.

/**
     * DOC bqian Comment method "findProcessFromRepository".
     * 
     * @param jobName
     * @return
     */
private IProcess2 findProcessFromRepository(String jobId, String version) {
    try {
        ItemCacheManager.clearCache();
        ProcessItem processItem = ItemCacheManager.getProcessItem(jobId, version);
        if (processItem != null) {
            if (GlobalServiceRegister.getDefault().isServiceRegistered(IDesignerCoreService.class)) {
                IDesignerCoreService service = (IDesignerCoreService) GlobalServiceRegister.getDefault().getService(IDesignerCoreService.class);
                IProcess process = service.getProcessFromItem(processItem);
                if (process instanceof IProcess2) {
                    return (IProcess2) process;
                }
            }
            // keep old code for now, but it should never be called.
            ProcessEditorInput fileEditorInput = new ProcessEditorInput(processItem, true, true, true);
            IProcess2 process = fileEditorInput.getLoadedProcess();
            return process;
        }
    } catch (Exception e) {
        ExceptionHandler.process(e);
    }
    return null;
}
Also used : ProcessItem(org.talend.core.model.properties.ProcessItem) IProcess2(org.talend.core.model.process.IProcess2) IDesignerCoreService(org.talend.designer.core.IDesignerCoreService) IProcess(org.talend.core.model.process.IProcess) CoreException(org.eclipse.core.runtime.CoreException) ProcessEditorInput(org.talend.designer.core.ui.editor.ProcessEditorInput)

Example 78 with IProcess

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

the class JobletContainer method refreshJobletConnections.

private void refreshJobletConnections() {
    Iterator<IConnection> inIterator = inputs.iterator();
    while (inIterator.hasNext()) {
        IConnection conn = inIterator.next();
        if (isCollapsed()) {
            ((Connection) conn).reconnect(conn.getSource(), this.node, conn.getLineStyle());
        } else {
            out: for (NodeContainer nodeContainer : this.nodeContainers) {
                Node connNode = nodeContainer.getNode();
                IElementParameter elePa = this.node.getElementParameter(connNode.getJoblet_unique_name());
                if (elePa != null) {
                    IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
                    IElementParameter elechild = null;
                    String uniqueName = null;
                    boolean isTri = service.isTriggerNode(connNode);
                    if (service != null && isTri) {
                        elechild = elePa.getChildParameters().get("COMPONENT_LIST");
                        uniqueName = conn.getMetaName();
                    } else {
                        elechild = elePa.getChildParameters().get("CONNECTION");
                        uniqueName = conn.getUniqueName();
                    }
                    if (elechild != null && elechild.getValue().equals(uniqueName)) {
                        List<? extends INodeConnector> connList = new JobletUtil().createConnectors(connNode, this.getProcess());
                        // modify///////////////////////////////////////////////////////////////////////////////////////////////////////
                        List<INodeConnector> inodeConnList = new ArrayList<INodeConnector>();
                        inodeConnList.addAll(connList);
                        inodeConnList.addAll(connNode.getListConnector());
                        connNode.setListConnector(inodeConnList);
                        // connNode.getListConnector().addAll(connList);
                        IMetadataTable iTable = this.node.getMetadataTable(connNode.getUniqueName());
                        if (iTable != null && !connNode.getMetadataList().contains(iTable)) {
                        // connNode.getMetadataList().add(iTable);
                        }
                        JobletConnectionReconnectCommand reConnectCommand = new JobletConnectionReconnectCommand(conn);
                        reConnectCommand.setNewTarget(connNode);
                        reConnectCommand.execute();
                        break;
                    } else if (getFlowInput(inputs).size() == 1 && !isTri && new JobletUtil().isJobletInput(connNode, this.getProcess())) {
                        for (IConnection flowConn : getFlowInput(inputs)) {
                            if (!flowConn.getUniqueName().equals(conn.getUniqueName())) {
                                continue out;
                            }
                        }
                        JobletConnectionReconnectCommand reConnectCommand = new JobletConnectionReconnectCommand(conn);
                        reConnectCommand.setNewTarget(connNode);
                        reConnectCommand.execute();
                        break;
                    }
                }
            }
        }
    }
    Iterator<IConnection> outIterator = outputs.iterator();
    while (outIterator.hasNext()) {
        IConnection conn = outIterator.next();
        if (isCollapsed()) {
            ((Connection) conn).reconnect(this.node, conn.getTarget(), conn.getLineStyle());
        } else {
            for (NodeContainer nodeContainer : this.nodeContainers) {
                Node connNode = nodeContainer.getNode();
                if (conn.getConnectorName().equals(connNode.getJoblet_unique_name())) {
                    List<? extends INodeConnector> connList = new JobletUtil().createConnectors(connNode, this.getProcess());
                    List<INodeConnector> inodeConnList = new ArrayList<INodeConnector>();
                    inodeConnList.addAll(connList);
                    inodeConnList.addAll(connNode.getListConnector());
                    connNode.setListConnector(inodeConnList);
                    // connNode.setListConnector(connList);
                    IMetadataTable iTable = this.node.getMetadataTable(connNode.getUniqueName());
                    if (iTable != null && !connNode.getMetadataList().contains(iTable)) {
                    // connNode.getMetadataList().add(iTable);
                    }
                    JobletConnectionReconnectCommand reConnectCommand = new JobletConnectionReconnectCommand(conn);
                    reConnectCommand.setNewSource(connNode);
                    reConnectCommand.execute();
                // return;
                }
            }
        }
    }
    if (!isCollapsed()) {
        for (NodeContainer nodeContainer : this.nodeContainers) {
            Node connNode = nodeContainer.getNode();
            IProcess jobletProcess = this.getNode().getComponent().getProcess();
            List<? extends INode> jobletNodes = jobletProcess.getGraphicalNodes();
            for (INode n : jobletNodes) {
                if (connNode.getJoblet_unique_name().equals(n.getUniqueName())) {
                    connNode.setDummy(n.isDummy());
                // connNode.setActivate(n.isActivate());
                }
            }
        }
    }
}
Also used : INode(org.talend.core.model.process.INode) Node(org.talend.designer.core.ui.editor.nodes.Node) INode(org.talend.core.model.process.INode) IConnection(org.talend.core.model.process.IConnection) Connection(org.talend.designer.core.ui.editor.connections.Connection) ArrayList(java.util.ArrayList) IConnection(org.talend.core.model.process.IConnection) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) INodeConnector(org.talend.core.model.process.INodeConnector) JobletConnectionReconnectCommand(org.talend.designer.core.ui.editor.cmd.JobletConnectionReconnectCommand) IJobletProviderService(org.talend.core.ui.IJobletProviderService) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) IElementParameter(org.talend.core.model.process.IElementParameter) ArrayList(java.util.ArrayList) List(java.util.List) IProcess(org.talend.core.model.process.IProcess)

Example 79 with IProcess

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

the class SqlMemoController method refreshConnectionCommand.

private Command refreshConnectionCommand() {
    // open sql builder in repository mode, just use query object, no need for connection information
    ConnectionParameters connParameters = new ConnectionParameters();
    String queryId = (String) elem.getPropertyValue(EParameterName.REPOSITORY_QUERYSTORE_TYPE.getName());
    Query query = MetadataToolHelper.getQueryFromRepository(queryId);
    DatabaseConnectionItem item = findRepositoryItem(queryId);
    if (item != null) {
        connParameters.setRepositoryName(item.getProperty().getLabel());
        connParameters.setRepositoryId(item.getProperty().getId());
    }
    connParameters.setQueryObject(query);
    connParameters.setQuery(query.getValue());
    TextUtil.setDialogTitle(TextUtil.SQL_BUILDER_TITLE_REP);
    String processName = null;
    if (elem instanceof IProcess) {
        processName = ((IProcess) elem).getName();
    } else if (elem instanceof INode) {
        processName = ((INode) elem).getProcess().getName();
    } else if (elem instanceof IConnection) {
        processName = ((IConnection) elem).getSource().getProcess().getName();
    }
    connParameters.setNodeReadOnly(false);
    connParameters.setFromRepository(true);
    ISQLBuilderService sqlBuilderService = (ISQLBuilderService) GlobalServiceRegister.getDefault().getService(ISQLBuilderService.class);
    Dialog sqlBuilder = sqlBuilderService.openSQLBuilderDialog(composite.getShell(), processName, connParameters);
    String sql = null;
    if (Window.OK == sqlBuilder.open()) {
        sql = connParameters.getQuery();
    }
    if (sql != null && !queryText.isDisposed()) {
        queryText.setText(sql);
        String propertyName = (String) openSQLEditorButton.getData(PARAMETER_NAME);
        return new PropertyChangeCommand(elem, propertyName, sql);
    }
    return null;
}
Also used : INode(org.talend.core.model.process.INode) PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) Query(org.talend.core.model.metadata.builder.connection.Query) ModelSelectionDialog(org.talend.commons.ui.swt.dialogs.ModelSelectionDialog) Dialog(org.eclipse.jface.dialogs.Dialog) ConnectionParameters(org.talend.core.sqlbuilder.util.ConnectionParameters) IConnection(org.talend.core.model.process.IConnection) IProcess(org.talend.core.model.process.IProcess) ISQLBuilderService(org.talend.core.ui.services.ISQLBuilderService) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem)

Example 80 with IProcess

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

the class SapSchemaTypeController method copySchemaFromChildJob.

/**
     * DOC hcw Comment method "copySchemaFromChildJob".
     *
     * @param runJobNode
     * @param item
     */
private void copySchemaFromChildJob(Node runJobNode, final Item item) {
    // 0004322: tRunJob can import the tBufferOutput schema from the son job
    if (runJobNode != null && item instanceof ProcessItem) {
        IDesignerCoreService service = CorePlugin.getDefault().getDesignerCoreService();
        IProcess process = service.getProcessFromProcessItem((ProcessItem) item);
        List<? extends INode> graphicalNodes = process.getGraphicalNodes();
        for (INode node : graphicalNodes) {
            if ((node != null) && node.getComponent().getName().equals("tBufferOutput")) {
                //$NON-NLS-1$
                List<IMetadataTable> list = node.getMetadataList();
                if (list.size() > 0) {
                    List<IMetadataTable> metadata = runJobNode.getMetadataList();
                    if (metadata.size() == 0) {
                        metadata.add(list.get(0).clone());
                    } else {
                        IMetadataTable table = metadata.get(0);
                        // clear schema of tRunJob, so we will replace with schema of tBufferOutput
                        table.getListColumns().clear();
                        List<IMetadataColumn> columns = list.get(0).getListColumns();
                        for (IMetadataColumn col : columns) {
                            table.getListColumns().add(col.clone());
                        }
                    }
                    // skip other tBufferOutput component
                    break;
                }
            }
        }
    }
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) INode(org.talend.core.model.process.INode) ProcessItem(org.talend.core.model.properties.ProcessItem) IDesignerCoreService(org.talend.designer.core.IDesignerCoreService) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) IProcess(org.talend.core.model.process.IProcess)

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