Search in sources :

Example 1 with DataConnection

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

the class StatsAndLogsManager method createDataConnectionForComponentOK.

private static DataConnection createDataConnectionForComponentOK(DataNode dataNode, DataNode commitNode) {
    DataConnection dataConnec = new DataConnection();
    dataConnec.setActivate(true);
    dataConnec.setLineStyle(EConnectionType.ON_COMPONENT_OK);
    dataConnec.setTraceConnection(false);
    //$NON-NLS-1$ //$NON-NLS-2$
    dataConnec.setName("after_" + dataNode.getUniqueName() + "_" + commitNode.getUniqueName());
    // dataConnec.setName(refSource.getUniqueName() + "_to_hash_" + connection.getName());
    dataConnec.setSource(dataNode);
    dataConnec.setTarget(commitNode);
    dataConnec.setConnectorName(EConnectionType.ON_COMPONENT_OK.getName());
    return dataConnec;
}
Also used : DataConnection(org.talend.designer.core.model.process.DataConnection)

Example 2 with DataConnection

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

the class StatsAndLogsManager method createDataConnectionForSubJobOK.

private static DataConnection createDataConnectionForSubJobOK(DataNode dataNode, DataNode commitNode) {
    DataConnection dataConnec = new DataConnection();
    dataConnec.setActivate(true);
    dataConnec.setLineStyle(EConnectionType.ON_SUBJOB_OK);
    dataConnec.setTraceConnection(false);
    //$NON-NLS-1$ //$NON-NLS-2$
    dataConnec.setName("sub_ok_" + dataNode.getUniqueName() + "_" + commitNode.getUniqueName());
    // dataConnec.setName(refSource.getUniqueName() + "_to_hash_" + connection.getName());
    dataConnec.setSource(dataNode);
    dataConnec.setTarget(commitNode);
    dataConnec.setConnectorName(EConnectionType.ON_SUBJOB_OK.getName());
    return dataConnec;
}
Also used : DataConnection(org.talend.designer.core.model.process.DataConnection)

Example 3 with DataConnection

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

the class StatsAndLogsManager method addConnection.

private static DataNode addConnection(DataNode connectionNode, IProcess process, String connectionUID, DataNode dataNode, List<DataNode> nodeList, DataNode commitNode) {
    IElementParameter param = dataNode.getElementParameter(EParameterName.USE_EXISTING_CONNECTION.getName());
    if (param != null) {
        param.setValue(Boolean.TRUE);
    }
    param = dataNode.getElementParameter(EParameterName.CONNECTION.getName());
    if (param != null) {
        param.setValue(connectionUID);
    }
    if (connectionNode == null) {
        IComponent component = null;
        String[] javaDbComponents = StatsAndLogsConstants.DB_OUTPUT_COMPONENTS;
        for (String dbComponent : javaDbComponents) {
            String connectionComponentName = null;
            if (OracleComponentHelper.filterOracleConnectionType((String) process.getElementParameter(EParameterName.DB_TYPE.getName()).getValue()).equals(dbComponent)) {
                if (dbComponent.endsWith("Output")) {
                    //$NON-NLS-1$
                    //$NON-NLS-1$
                    String substring = dbComponent.substring(0, dbComponent.lastIndexOf("Output"));
                    //$NON-NLS-1$
                    connectionComponentName = substring + "Connection";
                } else {
                    //$NON-NLS-1$
                    connectionComponentName = "tOracleConnection";
                }
                component = ComponentsFactoryProvider.getInstance().get(connectionComponentName, process.getComponentsType());
                if (component != null) {
                    connectionNode = new DataNode(component, connectionUID);
                    connectionNode.setSubProcessStart(true);
                    connectionNode.setActivate(true);
                    // check if shared parameter exist, if yes, use it ONLY when use the project settings.
                    // name for shared connection can be always the same, as we use only when project settings is
                    // activated.
                    IElementParameter elementParameter = connectionNode.getElementParameter(EParameterName.USE_SHARED_CONNECTION.getName());
                    if (elementParameter != null && elementParameter.getName() != null) {
                        elementParameter.setValue(Boolean.TRUE);
                        //$NON-NLS-1$
                        final String sharedConnName = "StatsAndLog_Shared_Connection";
                        if ((Boolean) process.getElementParameter(EParameterName.STATANDLOG_USE_PROJECT_SETTINGS.getName()).getValue()) {
                            connectionNode.getElementParameter(EParameterName.SHARED_CONNECTION_NAME.getName()).setValue(TalendTextUtils.addQuotes(sharedConnName));
                        } else {
                            String url = getUrl(process);
                            if (url == null || url.equals("")) {
                                // fix bug of stats/logs found for sybase
                                connectionNode.getElementParameter(EParameterName.SHARED_CONNECTION_NAME.getName()).setValue(TalendTextUtils.addQuotes(sharedConnName));
                            } else {
                                connectionNode.getElementParameter(EParameterName.SHARED_CONNECTION_NAME.getName()).setValue(//$NON-NLS-1$ //$NON-NLS-2$
                                url + "+" + TalendTextUtils.addQuotes("_" + sharedConnName));
                            }
                        }
                    }
                    setConnectionParameter(connectionNode, process, connectionUID, dataNode, nodeList);
                    if (connectionComponentName.contains("Oracle")) {
                        //$NON-NLS-1$
                        if (connectionNode.getElementParameter(EParameterName.CONNECTION_TYPE.getName()) != null) {
                            connectionNode.getElementParameter(EParameterName.CONNECTION_TYPE.getName()).setValue(dbComponent);
                        }
                    }
                    connectionNode.setProcess(process);
                    nodeList.add(connectionNode);
                    IComponent prejobComponent = ComponentsFactoryProvider.getInstance().get(TPREJOB, ComponentCategory.CATEGORY_4_DI.getName());
                    DataNode preNode = new DataNode(prejobComponent, PRE_STA_LOG_CON);
                    preNode.setStart(true);
                    preNode.setSubProcessStart(true);
                    preNode.setActivate(true);
                    preNode.setProcess(process);
                    nodeList.add(preNode);
                    DataConnection dataConnec = createDataConnectionForComponentOK(preNode, connectionNode);
                    ((List<IConnection>) preNode.getOutgoingConnections()).add(dataConnec);
                    ((List<IConnection>) connectionNode.getIncomingConnections()).add(dataConnec);
                }
            }
        }
    }
    DataConnection dataConnec = createDataConnectionForSubJobOK(dataNode, commitNode);
    ((List<IConnection>) dataNode.getOutgoingConnections()).add(dataConnec);
    ((List<IConnection>) commitNode.getIncomingConnections()).add(dataConnec);
    return connectionNode;
}
Also used : DataConnection(org.talend.designer.core.model.process.DataConnection) IComponent(org.talend.core.model.components.IComponent) DataNode(org.talend.designer.core.model.process.DataNode) IElementParameter(org.talend.core.model.process.IElementParameter) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

DataConnection (org.talend.designer.core.model.process.DataConnection)3 ArrayList (java.util.ArrayList)1 List (java.util.List)1 IComponent (org.talend.core.model.components.IComponent)1 IElementParameter (org.talend.core.model.process.IElementParameter)1 DataNode (org.talend.designer.core.model.process.DataNode)1