Search in sources :

Example 36 with IProcess

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

the class PropertyChangeCommand method getRelativeNodes.

private List<INode> getRelativeNodes(List<? extends IElementParameter> elementParameters) {
    List<INode> retList = null;
    if (elementParameters == null || elementParameters.size() == 0) {
        return retList;
    }
    IElement element = elementParameters.get(0).getElement();
    if (element instanceof Node) {
        Node operatingNode = (Node) element;
        IProcess process = operatingNode.getProcess();
        if (process == null) {
            return retList;
        }
        List<? extends INode> graphicNodes = process.getGraphicalNodes();
        if (graphicNodes == null || graphicNodes.size() == 0) {
            return retList;
        }
        String nodeName = operatingNode.getLabel();
        retList = new ArrayList<INode>();
        for (INode node : graphicNodes) {
            List<? extends IElementParameter> nodeElementParameters = node.getElementParameters();
            if (nodeElementParameters == null || nodeElementParameters.size() == 0) {
                continue;
            }
            for (IElementParameter elementParameter : nodeElementParameters) {
                if (elementParameter.getFieldType() == EParameterFieldType.COMPONENT_LIST) {
                    Object objName = elementParameter.getValue();
                    if (objName == null) {
                        continue;
                    }
                    String relatedComponentsName = objName.toString();
                    if (relatedComponentsName.equals(nodeName)) {
                        retList.add(node);
                    }
                }
            }
        }
    }
    return retList;
}
Also used : INode(org.talend.core.model.process.INode) IElement(org.talend.core.model.process.IElement) Node(org.talend.designer.core.ui.editor.nodes.Node) IGraphicalNode(org.talend.core.ui.process.IGraphicalNode) INode(org.talend.core.model.process.INode) IElementParameter(org.talend.core.model.process.IElementParameter) IProcess(org.talend.core.model.process.IProcess)

Example 37 with IProcess

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

the class ConnectionPart method getModelChildren.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gef.editparts.AbstractEditPart#getModelChildren()
     */
@Override
protected List getModelChildren() {
    List<Element> elements;
    elements = new ArrayList<Element>();
    elements.add(((Connection) getModel()).getConnectionLabel());
    elements.add(((Connection) getModel()).getPerformance());
    if (((Connection) getModel()).getResuming() != null) {
        elements.add(((Connection) getModel()).getResuming());
    }
    boolean monitorSupport = true;
    if (getParent() != null && getRoot() != null) {
        EditPart contents = getRoot().getContents();
        if (contents.getModel() instanceof IProcess) {
            IProcess currentProcess = (IProcess) contents.getModel();
            if (ComponentCategory.CATEGORY_4_MAPREDUCE.getName().endsWith(currentProcess.getComponentsType())) {
                monitorSupport = false;
            }
        }
    } else {
        IProcess currentProcess = ((Connection) getModel()).getSource().getProcess();
        if (ComponentCategory.CATEGORY_4_MAPREDUCE.getName().endsWith(currentProcess.getComponentsType())) {
            monitorSupport = false;
        }
    }
    if (monitorSupport) {
        if (((Connection) getModel()).getConnectionTrace() != null) {
            elements.add(((Connection) getModel()).getConnectionTrace());
        }
        // Add monitor label
        if (((Connection) getModel()).isMonitorConnection()) {
            elements.add(((Connection) getModel()).getMonitorLabel());
        }
    }
    return elements;
}
Also used : Element(org.talend.core.model.process.Element) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) EditPart(org.eclipse.gef.EditPart) AbstractConnectionEditPart(org.eclipse.gef.editparts.AbstractConnectionEditPart) IConnection(org.talend.core.model.process.IConnection) IProcess(org.talend.core.model.process.IProcess)

Example 38 with IProcess

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

the class ComponentChooseDialog method propaHadoopCfgChanges.

/**
     * DOC ycbai Comment method "propaHadoopCfgChanges".
     *
     * <P>
     * Propagate the changes from hadoop cluster to M/R process when drag&drop hadoop subnode from repository view to
     * M/R process.
     * </P>
     *
     * @param repositoryNode
     */
private void propaHadoopCfgChanges(IRepositoryNode repositoryNode) {
    if (repositoryNode == null || repositoryNode.getObject() == null) {
        return;
    }
    IHadoopClusterService hadoopClusterService = HadoopRepositoryUtil.getHadoopClusterService();
    if (hadoopClusterService == null || !hadoopClusterService.isHadoopSubnode(repositoryNode)) {
        return;
    }
    IProcess process = editor.getProcess();
    if (!ComponentCategory.CATEGORY_4_MAPREDUCE.getName().equals(process.getComponentsType()) && !ComponentCategory.CATEGORY_4_SPARK.getName().equals(process.getComponentsType()) && !ComponentCategory.CATEGORY_4_SPARKSTREAMING.getName().equals(process.getComponentsType())) {
        return;
    }
    if ((process instanceof IProcess2) && (((IProcess2) process).getProperty().getItem() instanceof JobletProcessItem)) {
        return;
    }
    Item subItem = repositoryNode.getObject().getProperty().getItem();
    String propertyParamName = MR_PROPERTY_PREFIX + EParameterName.PROPERTY_TYPE.getName();
    String propertyRepTypeParamName = MR_PROPERTY_PREFIX + EParameterName.REPOSITORY_PROPERTY_TYPE.getName();
    IElementParameter propertyParam = process.getElementParameter(propertyParamName);
    if (propertyParam == null) {
        return;
    }
    String repositoryValue = propertyParam.getRepositoryValue();
    if (repositoryValue == null) {
        return;
    }
    //$NON-NLS-1$
    String[] supportedRepositoryTypes = repositoryValue.split("\\|");
    String repositoryType = hadoopClusterService.getRepositoryTypeOfHadoopSubItem(subItem);
    if (!ArrayUtils.contains(supportedRepositoryTypes, repositoryType)) {
        return;
    }
    Item hadoopClusterItem = hadoopClusterService.getHadoopClusterBySubitemId(new Project(ProjectManager.getInstance().getProject(subItem)), subItem.getProperty().getId());
    String hadoopClusterId = hadoopClusterItem.getProperty().getId();
    if (EmfComponent.REPOSITORY.equals(propertyParam.getValue())) {
        // do nothing when select the same hadoop cluster.
        String propertyId = (String) process.getElementParameter(propertyRepTypeParamName).getValue();
        if (hadoopClusterId.equals(propertyId)) {
            return;
        }
    }
    Connection connection = ((ConnectionItem) subItem).getConnection();
    if (hadoopClusterService.hasDiffsFromClusterToProcess(subItem, process)) {
        boolean confirmUpdate = MessageDialog.openConfirm(editor.getSite().getShell(), //$NON-NLS-1$
        Messages.getString("TalendEditorDropTargetListener.updateHadoopCfgDialog.title"), //$NON-NLS-1$
        Messages.getString("TalendEditorDropTargetListener.updateHadoopCfgDialog.msg"));
        if (confirmUpdate) {
            // Update spark mode to YARN_CLIENT if repository
            if (ComponentCategory.CATEGORY_4_SPARK.getName().equals(process.getComponentsType()) || ComponentCategory.CATEGORY_4_SPARKSTREAMING.getName().equals(process.getComponentsType())) {
                IElementParameter sparkLocalParam = process.getElementParameter(HadoopConstants.SPARK_LOCAL_MODE);
                IElementParameter sparkParam = process.getElementParameter(HadoopConstants.SPARK_MODE);
                if (sparkLocalParam != null && (Boolean) (sparkLocalParam.getValue())) {
                    sparkLocalParam.setValue(false);
                }
                if (sparkParam != null && !HadoopConstants.SPARK_MODE_YARN_CLIENT.equals(sparkParam.getValue())) {
                    sparkParam.setValue(HadoopConstants.SPARK_MODE_YARN_CLIENT);
                }
            }
            propertyParam.setValue(EmfComponent.REPOSITORY);
            ChangeValuesFromRepository command = new ChangeValuesFromRepository(process, connection, propertyRepTypeParamName, subItem.getProperty().getId());
            execCommandStack(command);
        }
    }
}
Also used : ChangeValuesFromRepository(org.talend.designer.core.ui.editor.cmd.ChangeValuesFromRepository) ValidationRulesConnectionItem(org.talend.core.model.properties.ValidationRulesConnectionItem) ConnectionItem(org.talend.core.model.properties.ConnectionItem) MDMConnectionItem(org.talend.core.model.properties.MDMConnectionItem) SAPConnectionItem(org.talend.core.model.properties.SAPConnectionItem) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) EbcdicConnectionItem(org.talend.core.model.properties.EbcdicConnectionItem) HL7ConnectionItem(org.talend.core.model.properties.HL7ConnectionItem) PolylineConnection(org.eclipse.draw2d.PolylineConnection) MDMConnection(org.talend.core.model.metadata.builder.connection.MDMConnection) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) CDCConnection(org.talend.core.model.metadata.builder.connection.CDCConnection) Connection(org.talend.core.model.metadata.builder.connection.Connection) ValidationRulesConnectionItem(org.talend.core.model.properties.ValidationRulesConnectionItem) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) ConnectionItem(org.talend.core.model.properties.ConnectionItem) MDMConnectionItem(org.talend.core.model.properties.MDMConnectionItem) SQLPatternItem(org.talend.core.model.properties.SQLPatternItem) LinkRulesItem(org.talend.core.model.properties.LinkRulesItem) SAPConnectionItem(org.talend.core.model.properties.SAPConnectionItem) ProcessItem(org.talend.core.model.properties.ProcessItem) ContextItem(org.talend.core.model.properties.ContextItem) Item(org.talend.core.model.properties.Item) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) EbcdicConnectionItem(org.talend.core.model.properties.EbcdicConnectionItem) RulesItem(org.talend.core.model.properties.RulesItem) HL7ConnectionItem(org.talend.core.model.properties.HL7ConnectionItem) FileItem(org.talend.core.model.properties.FileItem) Project(org.talend.core.model.general.Project) IHadoopClusterService(org.talend.core.hadoop.IHadoopClusterService) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) IProcess2(org.talend.core.model.process.IProcess2) IElementParameter(org.talend.core.model.process.IElementParameter) IProcess(org.talend.core.model.process.IProcess)

Example 39 with IProcess

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

the class AbstractElementPropertySectionController method openSQLBuilder.

/**
     * DOC qzhang Comment method "openSQLBuilder".
     *
     * @param repositoryType
     * @param propertyName
     * @param query
     */
protected String openSQLBuilder(String repositoryType, String propertyName, String query) {
    if (repositoryType.equals(EmfComponent.BUILTIN)) {
        connParameters.setQuery(query);
        if (connParameters.isShowConfigParamDialog()) {
            if (!isUseExistingConnection()) {
                initConnectionParametersWithContext(elem, part.getProcess().getContextManager().getDefaultContext());
            } else {
                initConnectionParametersWithContext(connectionNode, part.getProcess().getContextManager().getDefaultContext());
            }
        }
        // add for bug TDI-20335
        if (part == null) {
            Shell parentShell = new Shell(composite.getShell().getDisplay());
            ISQLBuilderService service = (ISQLBuilderService) GlobalServiceRegister.getDefault().getService(ISQLBuilderService.class);
            Dialog sqlBuilder = service.openSQLBuilderDialog(parentShell, "", connParameters);
            sqlBuilder.open();
        } else {
            openSqlBuilderBuildIn(connParameters, propertyName);
        }
    } else if (repositoryType.equals(EmfComponent.REPOSITORY)) {
        //$NON-NLS-1$
        String repositoryName2 = "";
        String repositoryId = null;
        IElementParameter memoParam = elem.getElementParameter(propertyName);
        IElementParameter repositoryParam = null;
        for (IElementParameter param : elem.getElementParameters()) {
            if (param.getFieldType() == EParameterFieldType.PROPERTY_TYPE && param.getRepositoryValue().startsWith("DATABASE")) {
                repositoryParam = param;
                break;
            }
        }
        // in case no database property found, take the first property (to keep compatibility with old code)
        if (repositoryParam == null) {
            for (IElementParameter param : elem.getElementParameters()) {
                if (param.getFieldType() == EParameterFieldType.PROPERTY_TYPE) {
                    repositoryParam = param;
                    break;
                }
            }
        }
        if (repositoryParam != null) {
            IElementParameter itemFromRepository = repositoryParam.getChildParameters().get(EParameterName.REPOSITORY_PROPERTY_TYPE.getName());
            String value = (String) itemFromRepository.getValue();
            repositoryId = value;
            // for (String key : this.dynamicProperty.getRepositoryConnectionItemMap().keySet()) {
            // if (key.equals(value)) {
            // repositoryName2 =
            // this.dynamicProperty.getRepositoryConnectionItemMap().get(key).getProperty().getLabel();
            // }
            // }
            /* get connection item dynamictly,not from cache ,see 16969 */
            IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
            try {
                IRepositoryViewObject repobj = factory.getLastVersion(value);
                if (repobj != null) {
                    Property property = repobj.getProperty();
                    if (property != null) {
                        repositoryName2 = property.getLabel();
                    }
                }
            } catch (PersistenceException e) {
                ExceptionHandler.process(e);
            }
        }
        // When no repository avaiable on "Repository" mode, open a MessageDialog.
        if (repositoryName2 == null || repositoryName2.length() == 0) {
            MessageDialog.openError(composite.getShell(), Messages.getString("NoRepositoryDialog.Title"), //$NON-NLS-1$
            Messages.getString(//$NON-NLS-1$
            "NoRepositoryDialog.Text"));
            return null;
        }
        // Part maybe not exist
        //$NON-NLS-1$
        String processName = "";
        //$NON-NLS-1$
        String key = "";
        if (elem instanceof Node) {
            processName = ((Node) elem).getProcess().getName();
            key = processName + ((Node) elem).getUniqueName();
        } else if (elem instanceof IProcess) {
            processName = ((IProcess) elem).getName();
            key = processName;
        }
        key += repositoryName2;
        final Dialog builderDialog = sqlbuilers.get(key);
        if (!composite.isDisposed() && builderDialog != null && builderDialog.getShell() != null && !builderDialog.getShell().isDisposed()) {
            builderDialog.getShell().setActive();
        } else {
            connParameters.setRepositoryName(repositoryName2);
            if (repositoryId != null) {
                connParameters.setRepositoryId(repositoryId);
            }
            Shell parentShell = new Shell(composite.getShell().getDisplay());
            String nodeLabel = null;
            if (elem instanceof Node) {
                nodeLabel = (String) ((Node) elem).getElementParameter(EParameterName.LABEL.getName()).getValue();
            }
            TextUtil.setDialogTitle(processName, nodeLabel, elem.getElementName());
            ISQLBuilderService service = (ISQLBuilderService) GlobalServiceRegister.getDefault().getService(ISQLBuilderService.class);
            connParameters.setQuery(query);
            // first open Sql Builder,set true
            connParameters.setFirstOpenSqlBuilder(true);
            Dialog sqlBuilder = service.openSQLBuilderDialog(parentShell, processName, connParameters);
            sqlbuilers.put(key, sqlBuilder);
            if (Window.OK == sqlBuilder.open()) {
                if (!composite.isDisposed() && !connParameters.isNodeReadOnly()) {
                    String sql = connParameters.getQuery();
                    // modified by hyWang
                    if (!connParameters.getIfContextButtonCheckedFromBuiltIn()) {
                        sql = QueryUtil.checkAndAddQuotes(sql);
                    }
                    return sql;
                }
            }
        }
    }
    return null;
}
Also used : Shell(org.eclipse.swt.widgets.Shell) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) Dialog(org.eclipse.jface.dialogs.Dialog) ModelSelectionDialog(org.talend.commons.ui.swt.dialogs.ModelSelectionDialog) INode(org.talend.core.model.process.INode) IGraphicalNode(org.talend.core.ui.process.IGraphicalNode) Node(org.talend.designer.core.ui.editor.nodes.Node) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) IElementParameter(org.talend.core.model.process.IElementParameter) IDynamicProperty(org.talend.core.ui.properties.tab.IDynamicProperty) Property(org.talend.core.model.properties.Property) IProcess(org.talend.core.model.process.IProcess) ISQLBuilderService(org.talend.core.ui.services.ISQLBuilderService) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 40 with IProcess

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

the class UIManager method openNewOutputCreationDialog.

/**
     * DOC amaumont Comment method "openAddNewOutputDialog".
     * 
     * return tableName--joinTableName if creating join table
     */
public String openNewOutputCreationDialog() {
    final IProcess process = mapperManager.getAbstractMapComponent().getProcess();
    //$NON-NLS-1$
    String outputName = process.generateUniqueConnectionName("out");
    //        InputDialog id = new InputDialog(getMapperContainer().getShell(), Messages.getString("UIManager.addNewOutputTable"), //$NON-NLS-1$
    //                Messages.getString("UIManager.typeTableName"), outputName, new IInputValidator() { //$NON-NLS-1$
    //
    // public String isValid(String newText) {
    // if (!process.checkValidConnectionName(newText)) {
    //                            return Messages.getString("UIManager.tableNameIsNotValid"); //$NON-NLS-1$
    // }
    // return null;
    // }
    //
    // });
    // int response = id.open();
    // if (response == InputDialog.OK) {
    // return id.getValue();
    // }
    OutputAddDialog dialog = new OutputAddDialog(getShell(), mapperManager, outputName);
    if (Window.OK == dialog.open()) {
        String tableName = "";
        tableName = dialog.getTableName();
        if (dialog.isCreatingJoinTable()) {
            tableName = tableName + NAME_SEPARATOR + dialog.getJoinTableName();
        }
        return tableName;
    }
    return null;
}
Also used : OutputAddDialog(org.talend.designer.mapper.ui.dialog.OutputAddDialog) 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