Search in sources :

Example 31 with NodeContainer

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

the class JobletUtil method getModifyMap.

public Map<String, List<AbstractJobletContainer>> getModifyMap(List<Element> elem) {
    Map<String, List<AbstractJobletContainer>> jobletNodeMap = new HashMap<String, List<AbstractJobletContainer>>();
    for (Element element : elem) {
        if (element instanceof SubjobContainer) {
            for (NodeContainer container : ((SubjobContainer) element).getNodeContainers()) {
                if (container instanceof AbstractJobletContainer) {
                    String processID = container.getNode().getProcess().getId();
                    if (!jobletNodeMap.containsKey(processID)) {
                        List<AbstractJobletContainer> nodeList = new ArrayList<AbstractJobletContainer>();
                        nodeList.add((AbstractJobletContainer) container);
                        jobletNodeMap.put(processID, nodeList);
                    } else {
                        jobletNodeMap.get(processID).add((AbstractJobletContainer) container);
                    }
                }
            }
        }
    }
    return jobletNodeMap;
}
Also used : HashMap(java.util.HashMap) SubjobContainer(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainer) ISubjobContainer(org.talend.core.model.process.ISubjobContainer) Element(org.talend.core.model.process.Element) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) EList(org.eclipse.emf.common.util.EList) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer)

Example 32 with NodeContainer

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

the class JobletUtil method getConnSubjob.

public List<SubjobContainer> getConnSubjob(SubjobContainer sub, List<ISubjobContainer> proSubList) {
    List<SubjobContainer> subList = new ArrayList<SubjobContainer>();
    if (!proSubList.contains(sub)) {
        return subList;
    }
    for (NodeContainer container : sub.getNodeContainers()) {
        List<IConnection> inList = new ArrayList<IConnection>();
        List<IConnection> outList = new ArrayList<IConnection>();
        if ((container instanceof AbstractJobletContainer)) {
            // && ((JobletContainer) container).isCollapsed()
            inList.addAll(((JobletContainer) container).getInputs());
            outList.addAll(((JobletContainer) container).getOutputs());
        } else {
            inList.addAll(container.getNode().getIncomingConnections());
            outList.addAll(container.getNode().getOutgoingConnections());
        }
        for (IConnection conn : inList) {
            INode source = conn.getSource();
            if (source instanceof Node) {
                SubjobContainer tem = ((Node) conn.getSource()).getNodeContainer().getSubjobContainer();
                if (tem != null && sub != tem) {
                    if (subList.contains(tem) || !proSubList.contains(tem)) {
                        continue;
                    }
                    subList.add(tem);
                    proSubList.remove(tem);
                    subList.addAll(getConnSubjob(tem, proSubList));
                }
            }
        }
        for (IConnection conn : outList) {
            INode target = conn.getTarget();
            if (target instanceof Node) {
                SubjobContainer tem = ((Node) conn.getTarget()).getNodeContainer().getSubjobContainer();
                if (tem != null && sub != tem) {
                    if (subList.contains(tem) || !proSubList.contains(tem)) {
                        continue;
                    }
                    subList.add(tem);
                    proSubList.remove(tem);
                    subList.addAll(getConnSubjob(tem, proSubList));
                }
            }
        }
    }
    return subList;
}
Also used : INode(org.talend.core.model.process.INode) SubjobContainer(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainer) ISubjobContainer(org.talend.core.model.process.ISubjobContainer) Node(org.talend.designer.core.ui.editor.nodes.Node) IExternalNode(org.talend.core.model.process.IExternalNode) INode(org.talend.core.model.process.INode) JobletNode(org.talend.designer.joblet.model.JobletNode) ArrayList(java.util.ArrayList) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) IConnection(org.talend.core.model.process.IConnection)

Example 33 with NodeContainer

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

the class NodeErrorEditPart method refreshVisuals.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gef.editparts.AbstractEditPart#refreshVisuals()
     */
@Override
protected void refreshVisuals() {
    Node node = ((NodeContainer) ((NodeContainerPart) getParent()).getModel()).getNode();
    NodeLabel nodeLabel = node.getNodeLabel();
    NodeErrorFigure errorFig = (NodeErrorFigure) this.getFigure();
    Point loc = node.getLocation().getCopy();
    Dimension size = errorFig.getSize();
    loc.x = loc.x + (node.getSize().width - size.width) / 2;
    loc.y = loc.y + node.getSize().height + (nodeLabel.getLabelSize().height);
    Rectangle rectangle = new Rectangle(loc, size);
    ((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), rectangle);
}
Also used : Rectangle(org.eclipse.draw2d.geometry.Rectangle) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) Point(org.eclipse.draw2d.geometry.Point) Dimension(org.eclipse.draw2d.geometry.Dimension) AbstractGraphicalEditPart(org.eclipse.gef.editparts.AbstractGraphicalEditPart) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart)

Example 34 with NodeContainer

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

the class NodeErrorEditPart method propertyChange.

/*
     * (non-Javadoc)
     * 
     * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
     */
public void propertyChange(final PropertyChangeEvent evt) {
    String request = evt.getPropertyName();
    if (request.equals("UPDATE_STATUS")) {
        //$NON-NLS-1$
        NodeErrorFigure figure = (NodeErrorFigure) this.getFigure();
        Node node = ((NodeContainer) ((NodeContainerPart) getParent()).getModel()).getNode();
        figure.updateVisible(node.isErrorFlag(), node.getErrorInfo());
        ((NodeError) getModel()).setErrorSize((figure).getSize());
        refreshVisuals();
    }
    if (request.equals(NodeError.LOCATION)) {
        //$NON-NLS-1$
        refreshVisuals();
        getParent().refresh();
    }
    if (request.equals(EParameterName.ACTIVATE.getName())) {
        if (((NodeError) getModel()).isActivate()) {
            ((NodeErrorFigure) figure).setAlpha(-1);
            ((NodeErrorFigure) figure).repaint();
            refreshVisuals();
        } else {
            ((NodeErrorFigure) figure).setAlpha(Node.ALPHA_VALUE);
            ((NodeErrorFigure) figure).repaint();
            refreshVisuals();
        }
    }
    EditPart editPart = getParent();
    if (editPart != null) {
        while ((!(editPart instanceof ProcessPart)) && (!(editPart instanceof SubjobContainerPart))) {
            editPart = editPart.getParent();
        }
        if (editPart instanceof SubjobContainerPart) {
            editPart.refresh();
        }
    }
}
Also used : AbstractGraphicalEditPart(org.eclipse.gef.editparts.AbstractGraphicalEditPart) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) EditPart(org.eclipse.gef.EditPart) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) ProcessPart(org.talend.designer.core.ui.editor.process.ProcessPart) SubjobContainerPart(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart)

Example 35 with NodeContainer

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

the class GuessSchemaProcess method buildProcess.

private void buildProcess() {
    process = new Process(property);
    process.getContextManager().getListContext().addAll(node.getProcess().getContextManager().getListContext());
    process.getContextManager().setDefaultContext(this.selectContext);
    outputComponent = ComponentsFactoryProvider.getInstance().get(EDatabaseComponentName.FILEDELIMITED.getOutPutComponentName(), ComponentCategory.CATEGORY_4_DI.getName());
    if (node.getModulesNeeded().size() > 0 && !node.getComponent().getName().equals("tRedshiftInput")) {
        //$NON-NLS-1$
        for (ModuleNeeded module : node.getModulesNeeded()) {
            if (module.isRequired(node.getElementParameters())) {
                Node libNode1 = new Node(ComponentsFactoryProvider.getInstance().get(LIB_NODE, ComponentCategory.CATEGORY_4_DI.getName()), process);
                //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                libNode1.setPropertyValue("LIBRARY", "\"" + module.getModuleName() + "\"");
                NodeContainer nc = process.loadNodeContainer(libNode1, false);
                process.addNodeContainer(nc);
            }
        }
    } else {
        // hywang add for 9594
        if (node.getComponent().getName().equals("tJDBCInput") || node.getComponent().getName().equals("tRedshiftInput")) {
            List<String> drivers = EDatabaseVersion4Drivers.getDrivers(info.getTrueDBTypeForJDBC(), info.getDbVersion());
            String moduleNeedName = "";
            Node libNode1 = new Node(ComponentsFactoryProvider.getInstance().get(LIB_NODE, ComponentCategory.CATEGORY_4_DI.getName()), process);
            if (drivers.size() > 0) {
                // use the first driver as defalult.
                // added for bug 13592
                moduleNeedName = drivers.get(0).toString();
                //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                libNode1.setPropertyValue("LIBRARY", "\"" + moduleNeedName + "\"");
            }
            process.addNodeContainer(new NodeContainer(libNode1));
        }
    }
    INode connectionNode = null;
    IElementParameter existConnection = node.getElementParameter("USE_EXISTING_CONNECTION");
    boolean useExistConnection = (existConnection == null ? false : (Boolean) existConnection.getValue());
    if (useExistConnection) {
        IElementParameter connector = node.getElementParameter("CONNECTION");
        if (connector != null) {
            String connectorValue = connector.getValue().toString();
            List<? extends INode> generatingNodes = originalProcess.getGeneratingNodes();
            for (INode node : generatingNodes) {
                if (node.getUniqueName().equals(connectorValue)) {
                    connectionNode = node;
                    break;
                }
            }
        }
    }
    List<ModuleNeeded> neededLibraries = new ArrayList<ModuleNeeded>();
    JavaProcessUtil.addNodeRelatedModules(process, neededLibraries, node);
    for (ModuleNeeded module : neededLibraries) {
        Node libNode1 = new Node(ComponentsFactoryProvider.getInstance().get(LIB_NODE), process);
        //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        libNode1.setPropertyValue("LIBRARY", "\"" + module.getModuleName() + "\"");
        process.addNodeContainer(new NodeContainer(libNode1));
    }
    if (connectionNode != null) {
        neededLibraries = new ArrayList<ModuleNeeded>();
        JavaProcessUtil.addNodeRelatedModules(process, neededLibraries, connectionNode);
        for (ModuleNeeded module : neededLibraries) {
            Node libNode1 = new Node(ComponentsFactoryProvider.getInstance().get(LIB_NODE), process);
            //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
            libNode1.setPropertyValue("LIBRARY", "\"" + module.getModuleName() + "\"");
            process.addNodeContainer(new NodeContainer(libNode1));
        }
    }
    // create the tLibraryLoad for the output component which is "tFileOutputDelimited"
    for (ModuleNeeded module : outputComponent.getModulesNeeded()) {
        Node libNode2 = new Node(ComponentsFactoryProvider.getInstance().get(LIB_NODE), process);
        //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        libNode2.setPropertyValue("LIBRARY", "\"" + module.getModuleName() + "\"");
        process.addNodeContainer(new NodeContainer(libNode2));
    }
    // for sql statement, feature 6622.
    int fetchSize = maximumRowsToPreview;
    if (maximumRowsToPreview > 1000) {
        fetchSize = 1000;
    }
    String codeStart, codeMain, codeEnd;
    temppath = buildTempCSVFilename();
    // Should also replace "/r". NMa.
    // ISO-8859-15
    memoSQL = memoSQL.replace("\r", " ");
    // fix for TDI-26285
    //$NON-NLS-1$
    String createStatament = "conn.createStatement(java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE,java.sql.ResultSet.CONCUR_READ_ONLY)";
    //$NON-NLS-1$ 
    String systemProperty = "";
    if (info.isHive()) {
        //$NON-NLS-1$ 
        createStatament = "conn.createStatement()";
        systemProperty = //$NON-NLS-1$ //$NON-NLS-2$ 
        "System.setProperty(\"mapred.job.tracker\",\"" + info.getJobTracker() + "\");\r\n" + "System.setProperty(\"fs.default.name\", \"" + info.getNameNode() + //$NON-NLS-1$ //$NON-NLS-2$ 
        "\");\r\n";
        // only embeded hive need the following params
        if (info.getThrifturi() != null) {
            systemProperty = //$NON-NLS-1$ 
            systemProperty + " System.setProperty(\"hive.metastore.local\", \"false\");\r\n" + " System.setProperty(\"hive.metastore.uris\", \"" + info.getThrifturi() + //$NON-NLS-1$ //$NON-NLS-2$ 
            "\");\r\n" + //$NON-NLS-1$ 
            "System.setProperty(\"hive.metastore.execute.setugi\", \"true\");\r\n";
        }
    }
    // add for bug TDI-27137 by fwang on 27 August, 2013.
    EDatabaseTypeName dbType = EDatabaseTypeName.JAVADB_EMBEDED.getTypeFromDbType(info.getDbType());
    if (EDatabaseTypeName.JAVADB_EMBEDED.equals(dbType)) {
        IElementParameter dbPathElement = node.getElementParameter("DBPATH");
        if (dbPathElement != null) {
            String derbyPath = dbPathElement.getValue().toString().replace("\"", "").trim();
            systemProperty = systemProperty + "System.setProperty(\"derby.system.home\",\"" + derbyPath + "\");\r\n";
        }
    }
    // the Sqlite
    if (EDatabaseTypeName.SQLITE.getXmlName().equals(info.getDbType())) {
        createStatament = "conn.createStatement()";
    }
    // the VERTICA
    if (ConnectionUtils.isVertica(info.getUrl())) {
        createStatament = "conn.createStatement()";
    }
    if (EDatabaseTypeName.GENERAL_JDBC.getXmlName().equals(info.getDbType()) && "com.sap.db.jdbc.Driver".equals(info.getDriverClassName()) || EDatabaseTypeName.SAPHana.getXmlName().equals(info.getDbType())) {
        createStatament = "conn.createStatement()";
    }
    codeStart = systemProperty + getCodeStart(connectionNode, createStatament, fetchSize);
    codeMain = //$NON-NLS-1$ //$NON-NLS-2$
    "String[] dataOneRow = new String[numbOfColumn];\r\n" + "for (int i = 1; i <= numbOfColumn; i++) {\r\n" + "    \r\n" + " try{\r\n" + "    String tempStr = rs.getString(i);\r\n" + "    dataOneRow[i-1] = tempStr;\r\n" + "      } catch (java.sql.SQLException e) {\r\n" + "}\r\n" + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
    "}\r\n" + //$NON-NLS-1$
    "csvWriter.writeNext(dataOneRow);";
    if (EDatabaseTypeName.REDSHIFT.getXmlName().equals(info.getDbType())) {
        codeEnd = //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
        "nbRows++;\r\n" + "    if (nbRows > " + maximumRowsToPreview + ") break;\r\n" + "}\r\n" + "conn.close();\r\n" + //$NON-NLS-1$ //$NON-NLS-2$
        "csvWriter.close();\r\n";
    } else {
        codeEnd = //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
        "nbRows++;\r\n" + "    if (nbRows > " + maximumRowsToPreview + ") break;\r\n" + "}\r\n" + "conn.close();\r\n" + //$NON-NLS-1$ //$NON-NLS-2$
        "csvWriter.close();\r\n";
    }
    IComponent component = null;
    switch(LanguageManager.getCurrentLanguage()) {
        case JAVA:
            //$NON-NLS-1$
            component = ComponentsFactoryProvider.getInstance().get("tJavaFlex");
            break;
        case PERL:
        default:
            //$NON-NLS-1$
            component = ComponentsFactoryProvider.getInstance().get("tPerlFlex");
            break;
    }
    Node flexNode = new Node(component, process);
    //$NON-NLS-1$
    flexNode.setPropertyValue("CODE_START", codeStart);
    //$NON-NLS-1$
    flexNode.setPropertyValue("CODE_MAIN", codeMain);
    //$NON-NLS-1$
    flexNode.setPropertyValue("CODE_END", codeEnd);
    process.addNodeContainer(new NodeContainer(flexNode));
}
Also used : INode(org.talend.core.model.process.INode) IComponent(org.talend.core.model.components.IComponent) Node(org.talend.designer.core.ui.editor.nodes.Node) INode(org.talend.core.model.process.INode) ArrayList(java.util.ArrayList) IProcess(org.talend.core.model.process.IProcess) Process(org.talend.designer.core.ui.editor.process.Process) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) IElementParameter(org.talend.core.model.process.IElementParameter) EDatabaseTypeName(org.talend.core.database.EDatabaseTypeName) ModuleNeeded(org.talend.core.model.general.ModuleNeeded)

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