Search in sources :

Example 11 with DataNode

use of org.talend.designer.core.model.process.DataNode 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)

Example 12 with DataNode

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

the class StatsAndLogsManager method createMetterNode.

private static DataNode createMetterNode(boolean useFile, boolean console, String dbOutput) {
    JobMetterComponent statsComponent = new JobMetterComponent(useFile, console, dbOutput);
    DataNode statsNode = new DataNode(statsComponent, METER_UNIQUE_NAME);
    statsNode.setStart(true);
    statsNode.setSubProcessStart(true);
    statsNode.setActivate(true);
    statsNode.getMetadataList().clear();
    // load the tFlowMeterCatcher to get the schema.
    IComponent tmpComponent = ComponentsFactoryProvider.getInstance().get("tFlowMeterCatcher", //$NON-NLS-1$
    ComponentCategory.CATEGORY_4_DI.getName());
    //$NON-NLS-1$
    DataNode tmpNode = new DataNode(tmpComponent, "tmp");
    boolean found = false;
    for (int k = 0; k < tmpNode.getElementParameters().size() && !found; k++) {
        IElementParameter currentParam = tmpNode.getElementParameters().get(k);
        if (currentParam.getFieldType().equals(EParameterFieldType.SCHEMA_TYPE) || currentParam.getFieldType().equals(EParameterFieldType.SCHEMA_REFERENCE)) {
            Object value = currentParam.getValue();
            if (value instanceof IMetadataTable) {
                IMetadataTable table = ((IMetadataTable) value).clone();
                table.setTableName(METER_UNIQUE_NAME);
                table.setAttachedConnector(currentParam.getContext());
                statsNode.getMetadataList().add(table);
            }
            found = true;
        }
    }
    return statsNode;
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) DataNode(org.talend.designer.core.model.process.DataNode) IComponent(org.talend.core.model.components.IComponent) IElementParameter(org.talend.core.model.process.IElementParameter)

Example 13 with DataNode

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

the class NodeUtilTest method testIsBigDataFrameworkNode.

@Test
public void testIsBigDataFrameworkNode() {
    DummyComponent comp = Mockito.mock(DummyComponent.class);
    Mockito.when(comp.getType()).thenReturn(ComponentCategory.CATEGORY_4_CAMEL.getName());
    //$NON-NLS-1$
    INode node = new DataNode(comp, "");
    assertFalse(NodeUtil.isBigDataFrameworkNode(node));
    Mockito.when(comp.getType()).thenReturn(ComponentCategory.CATEGORY_4_DI.getName());
    //$NON-NLS-1$
    node = new DataNode(comp, "");
    assertFalse(NodeUtil.isBigDataFrameworkNode(node));
    Mockito.when(comp.getType()).thenReturn(ComponentCategory.CATEGORY_4_MAPREDUCE.getName());
    //$NON-NLS-1$
    node = new DataNode(comp, "");
    assertTrue(NodeUtil.isBigDataFrameworkNode(node));
    Mockito.when(comp.getType()).thenReturn(ComponentCategory.CATEGORY_4_SPARK.getName());
    //$NON-NLS-1$
    node = new DataNode(comp, "");
    assertTrue(NodeUtil.isBigDataFrameworkNode(node));
    Mockito.when(comp.getType()).thenReturn(ComponentCategory.CATEGORY_4_SPARKSTREAMING.getName());
    //$NON-NLS-1$
    node = new DataNode(comp, "");
    assertTrue(NodeUtil.isBigDataFrameworkNode(node));
    Mockito.when(comp.getType()).thenReturn(ComponentCategory.CATEGORY_4_STORM.getName());
    //$NON-NLS-1$
    node = new DataNode(comp, "");
    assertTrue(NodeUtil.isBigDataFrameworkNode(node));
}
Also used : INode(org.talend.core.model.process.INode) DummyComponent(org.talend.designer.core.model.components.DummyComponent) DataNode(org.talend.designer.core.model.process.DataNode) Test(org.junit.Test)

Aggregations

DataNode (org.talend.designer.core.model.process.DataNode)13 IComponent (org.talend.core.model.components.IComponent)9 IElementParameter (org.talend.core.model.process.IElementParameter)9 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)6 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)4 INode (org.talend.core.model.process.INode)4 IMetadataColumn (org.talend.core.model.metadata.IMetadataColumn)3 DummyComponent (org.talend.designer.core.model.components.DummyComponent)3 ElementParameter (org.talend.designer.core.model.components.ElementParameter)2 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 EDatabaseTypeName (org.talend.core.database.EDatabaseTypeName)1 IComponentsFactory (org.talend.core.model.components.IComponentsFactory)1 ModuleNeeded (org.talend.core.model.general.ModuleNeeded)1 DummyMetadataTalendTypeFilter (org.talend.core.model.metadata.DummyMetadataTalendTypeFilter)1 MetadataTalendTypeFilter (org.talend.core.model.metadata.MetadataTalendTypeFilter)1 MrMetadataTalendTypeFilter (org.talend.core.model.metadata.MrMetadataTalendTypeFilter)1 SparkMetadataTalendTypeFilter (org.talend.core.model.metadata.SparkMetadataTalendTypeFilter)1