Search in sources :

Example 6 with DataNode

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

the class JobSettingsManagerTest method testCreateExtraContextLoadNodes.

/**
     * Test method for
     * {@link org.talend.designer.core.model.process.jobsettings.JobSettingsManager#createExtraContextLoadNodes(org.talend.core.model.process.IProcess)}
     * .
     */
@Test
public void testCreateExtraContextLoadNodes() {
    // junit for TUP-3972
    Property property = PropertiesFactory.eINSTANCE.createProperty();
    IProcess2 process = new Process(property);
    process.getElementParameter(EParameterName.IMPLICIT_TCONTEXTLOAD.getName()).setValue(true);
    process.getElementParameter(EParameterName.IMPLICIT_TCONTEXTLOAD_FILE.getName()).setValue("the test file");
    process.getElementParameter("FROM_FILE_FLAG_IMPLICIT_CONTEXT").setValue(true);
    final List<DataNode> createContextLoadNodes = JobSettingsManager.createExtraContextLoadNodes(process);
    assertNotEquals(createContextLoadNodes.size(), 0);
    final DataNode dataNode = createContextLoadNodes.get(0);
    final IMetadataTable metadataTable = dataNode.getMetadataList().get(0);
    for (IMetadataColumn column : metadataTable.getListColumns()) {
        assertNotNull(column.getDefault());
        assertNotNull(JavaTypesManager.getDefaultValueFromJavaType(column.getTalendType(), column.getDefault()));
    }
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) DataNode(org.talend.designer.core.model.process.DataNode) IProcess2(org.talend.core.model.process.IProcess2) Process(org.talend.designer.core.ui.editor.process.Process) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) Property(org.talend.core.model.properties.Property) Test(org.junit.Test)

Example 7 with DataNode

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

the class JavaProcessUtilTest method testFindMoreLibraries.

@Test
public void testFindMoreLibraries() {
    // ensure the CAMEL is not added as jar dependency
    DummyComponent comp = mock(DummyComponent.class);
    when(comp.getType()).thenReturn(ComponentCategory.CATEGORY_4_CAMEL.getName());
    //$NON-NLS-1$
    INode node = new DataNode(comp, "");
    IElementParameter param = new ElementParameter(node);
    param.setName("HOTLIBS");
    List<Map<String, Object>> table = new ArrayList<Map<String, Object>>();
    Map<String, Object> line = new HashMap<String, Object>();
    line.put("LIBPATH", "CAMEL");
    table.add(line);
    param.setValue(table);
    List<ModuleNeeded> modulesNeeded = new ArrayList<ModuleNeeded>();
    JavaProcessUtil.findMoreLibraries(null, modulesNeeded, param);
    assertTrue(modulesNeeded.isEmpty());
    table = new ArrayList<Map<String, Object>>();
    line = new HashMap<String, Object>();
    line.put("LIBPATH", "\"camel.jar\"");
    table.add(line);
    param.setValue(table);
    modulesNeeded = new ArrayList<ModuleNeeded>();
    JavaProcessUtil.findMoreLibraries(null, modulesNeeded, param);
    assertEquals(1, modulesNeeded.size());
    assertEquals("camel.jar", modulesNeeded.get(0).getModuleName());
}
Also used : INode(org.talend.core.model.process.INode) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) IElementParameter(org.talend.core.model.process.IElementParameter) ElementParameter(org.talend.designer.core.model.components.ElementParameter) DummyComponent(org.talend.designer.core.model.components.DummyComponent) DataNode(org.talend.designer.core.model.process.DataNode) IElementParameter(org.talend.core.model.process.IElementParameter) HashMap(java.util.HashMap) Map(java.util.Map) ModuleNeeded(org.talend.core.model.general.ModuleNeeded) Test(org.junit.Test)

Example 8 with DataNode

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

the class NodeUtilTest method createMetadataTalendTypeFilter.

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

Example 9 with DataNode

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

the class JobSettingsManager method createExtraContextLoadNodes.

public static List<DataNode> createExtraContextLoadNodes(IProcess process) {
    List<DataNode> nodeList = new ArrayList<DataNode>();
    String paramName = EParameterName.IMPLICIT_TCONTEXTLOAD.getName();
    boolean useContextLoad = ((Boolean) process.getElementParameter(paramName).getValue()) && process.getElementParameter(paramName).isShow(process.getElementParameters());
    if (!useContextLoad) {
        // not used
        return Collections.emptyList();
    }
    // file
    paramName = JobSettingsConstants.getExtraParameterName(EParameterName.FROM_FILE_FLAG.getName());
    boolean fileFlag = ((Boolean) process.getElementParameter(paramName).getValue()) && process.getElementParameter(paramName).isShow(process.getElementParameters());
    // db
    String dbInput = null;
    paramName = JobSettingsConstants.getExtraParameterName(EParameterName.FROM_DATABASE_FLAG.getName());
    boolean dbFlag = ((Boolean) process.getElementParameter(paramName).getValue()) && process.getElementParameter(paramName).isShow(process.getElementParameters());
    if (!dbFlag) {
        dbInput = null;
    } else {
        dbInput = (String) process.getElementParameter(JobSettingsConstants.getExtraParameterName(EParameterName.DB_TYPE.getName())).getValue();
        dbInput = OracleComponentHelper.filterOracleComponentName(dbInput);
        if (dbInput == null || dbInput.equals("")) {
            //$NON-NLS-1$
            dbInput = null;
            dbFlag = false;
        }
    }
    if (!fileFlag && !dbFlag) {
        // not used
        return Collections.emptyList();
    }
    IComponent tContextLoadComponent = new JobContextLoadComponent(fileFlag, dbInput);
    //$NON-NLS-1$
    final String uniqueName = "Implicit_Context";
    DataNode tContextLoadNode = new DataNode(tContextLoadComponent, uniqueName);
    tContextLoadNode.setStart(true);
    tContextLoadNode.setSubProcessStart(true);
    tContextLoadNode.setActivate(true);
    IMetadataTable table = getSchemaTablefromComponent(JobContextLoadComponent.CONTEXTLOAD_COMPONENT, uniqueName);
    if (table != null) {
        tContextLoadNode.getMetadataList().clear();
        tContextLoadNode.getMetadataList().add(table);
    }
    // set parameters
    IElementParameter param = null;
    if (fileFlag) {
        // is file
        String inputFile = (String) process.getElementParameter(EParameterName.IMPLICIT_TCONTEXTLOAD_FILE.getName()).getValue();
        String fileSparator = (String) process.getElementParameter(EParameterName.FIELDSEPARATOR.getName()).getValue();
        tContextLoadNode.getElementParameter(EParameterName.IMPLICIT_TCONTEXTLOAD_FILE.getName()).setValue(inputFile);
        String regex = FileSeparator.getSeparatorsRegexp(TalendQuoteUtils.removeQuotes(fileSparator));
        tContextLoadNode.getElementParameter(JobSettingsConstants.IMPLICIT_TCONTEXTLOAD_REGEX).setValue(regex);
    } else {
        // is db
        paramName = JobSettingsConstants.getExtraParameterName(EParameterName.URL.getName());
        param = process.getElementParameter(paramName);
        if (param != null) {
            tContextLoadNode.getElementParameter(paramName).setValue(param.getValue());
        }
        paramName = JobSettingsConstants.getExtraParameterName(EParameterName.DRIVER_JAR.getName());
        param = process.getElementParameter(paramName);
        if (param != null) {
            tContextLoadNode.getElementParameter(paramName).setValue(param.getValue());
        }
        paramName = JobSettingsConstants.getExtraParameterName(EParameterName.DRIVER_CLASS.getName());
        param = process.getElementParameter(paramName);
        if (param != null) {
            tContextLoadNode.getElementParameter(paramName).setValue(param.getValue());
        }
        paramName = JobSettingsConstants.getExtraParameterName(EParameterName.HOST.getName());
        tContextLoadNode.getElementParameter(paramName).setValue(process.getElementParameter(paramName).getValue());
        paramName = JobSettingsConstants.getExtraParameterName(EParameterName.PORT.getName());
        tContextLoadNode.getElementParameter(paramName).setValue(process.getElementParameter(paramName).getValue());
        paramName = JobSettingsConstants.getExtraParameterName(EParameterName.DBNAME.getName());
        tContextLoadNode.getElementParameter(paramName).setValue(process.getElementParameter(paramName).getValue());
        paramName = JobSettingsConstants.getExtraParameterName(EParameterName.DB_VERSION.getName());
        tContextLoadNode.getElementParameter(paramName).setValue(process.getElementParameter(paramName).getValue());
        paramName = JobSettingsConstants.getExtraParameterName(EParameterName.PROPERTIES.getName());
        param = process.getElementParameter(paramName);
        if (param != null) {
            tContextLoadNode.getElementParameter(paramName).setValue(param.getValue());
        }
        paramName = JobSettingsConstants.getExtraParameterName(EParameterName.SCHEMA_DB.getName());
        param = process.getElementParameter(paramName);
        if (param != null) {
            tContextLoadNode.getElementParameter(paramName).setValue(param.getValue());
        }
        String schema = (String) process.getElementParameter(paramName).getValue();
        if (schema != null) {
            schema = TalendTextUtils.removeQuotes(schema);
        }
        paramName = JobSettingsConstants.getExtraParameterName(EParameterName.USER.getName());
        tContextLoadNode.getElementParameter(paramName).setValue(process.getElementParameter(paramName).getValue());
        paramName = JobSettingsConstants.getExtraParameterName(EParameterName.PASS.getName());
        tContextLoadNode.getElementParameter(paramName).setValue(process.getElementParameter(paramName).getValue());
        paramName = JobSettingsConstants.getExtraParameterName(EParameterName.CONNECTION_TYPE.getName());
        tContextLoadNode.getElementParameter(paramName).setValue(OracleComponentHelper.filterOracleConnectionType((String) process.getElementParameter(JobSettingsConstants.getExtraParameterName(EParameterName.DB_TYPE.getName())).getValue()));
        paramName = JobSettingsConstants.getExtraParameterName(EParameterName.DBTABLE.getName());
        tContextLoadNode.getElementParameter(paramName).setValue(process.getElementParameter(paramName).getValue());
        // query
        String dbTableName = (String) process.getElementParameter(paramName).getValue();
        String realTableName = getCurrentTableName(dbTableName);
        if (realTableName == null) {
            realTableName = QueryUtil.DEFAULT_TABLE_NAME;
        }
        String dbType = getDatabaseTypeFromParameter(process);
        if (dbType != null) {
            // TDI-18161:the SQL script's syntax is not right because of the implicit context of General JDBC.
            if (dbType.equals(EDatabaseTypeName.GENERAL_JDBC.getDisplayName())) {
                dbType = findRealDbTypeForJDBC(process, dbType);
            }
            EDatabaseTypeName dbTypeName = EDatabaseTypeName.getTypeFromDbType(dbType);
            if (EDatabaseTypeName.ORACLE_OCI.equals(dbTypeName) || EDatabaseTypeName.ORACLEFORSID.equals(dbTypeName) || EDatabaseTypeName.ORACLESN.equals(dbTypeName)) {
                for (IMetadataColumn column : table.getListColumns()) {
                    column.setOriginalDbColumnName(column.getOriginalDbColumnName().toUpperCase());
                }
            }
            if (realTableName.startsWith(TalendTextUtils.QUOTATION_MARK) && realTableName.endsWith(TalendTextUtils.QUOTATION_MARK) && realTableName.length() > 2) {
                realTableName = realTableName.substring(1, realTableName.length() - 1);
            }
            String query = TalendTextUtils.addSQLQuotes(QueryUtil.generateNewQuery(null, table, dbType, schema, realTableName));
            paramName = JobSettingsConstants.getExtraParameterName(EParameterName.QUERY_CONDITION.getName());
            String conditionStatement = (String) process.getElementParameter(paramName).getValue();
            if (conditionStatement != null) {
                String tmp = TalendTextUtils.removeQuotes(conditionStatement);
                if (!"".equals(tmp)) {
                    //$NON-NLS-1$
                    //$NON-NLS-1$
                    query = query + CONNECTOR + QUOTE + " WHERE " + QUOTE + CONNECTOR + conditionStatement;
                }
            }
            final String quoteByDBType = TalendTextUtils.getQuoteByDBType(dbType, false);
            if (dbTypeName == EDatabaseTypeName.MSSQL) {
                query = //$NON-NLS-1$
                query.replaceAll(//$NON-NLS-1$
                "(?i)\bkey\b", //$NON-NLS-1$  //$NON-NLS-2$
                "\\\\" + quoteByDBType + "key\\\\" + quoteByDBType);
            }
            tContextLoadNode.getElementParameter(JobSettingsConstants.QUERY).setValue(query);
        }
    }
    // tContextLoad
    paramName = EParameterName.LOAD_NEW_VARIABLE.getName();
    param = process.getElementParameter(paramName);
    if (param != null) {
        tContextLoadNode.getElementParameter(paramName).setValue(param.getValue());
    }
    paramName = EParameterName.NOT_LOAD_OLD_VARIABLE.getName();
    param = process.getElementParameter(paramName);
    if (param != null) {
        tContextLoadNode.getElementParameter(paramName).setValue(param.getValue());
    }
    paramName = EParameterName.PRINT_OPERATIONS.getName();
    tContextLoadNode.getElementParameter(paramName).setValue(process.getElementParameter(paramName).getValue());
    paramName = EParameterName.DISABLE_ERROR.getName();
    param = process.getElementParameter(paramName);
    if (param != null) {
        tContextLoadNode.getElementParameter(paramName).setValue(param.getValue());
    }
    paramName = EParameterName.DISABLE_INFO.getName();
    param = process.getElementParameter(paramName);
    if (param != null) {
        tContextLoadNode.getElementParameter(paramName).setValue(param.getValue());
    }
    paramName = EParameterName.DISABLE_WARNINGS.getName();
    tContextLoadNode.getElementParameter(paramName).setValue(process.getElementParameter(paramName).getValue());
    tContextLoadNode.setProcess(process);
    nodeList.add(tContextLoadNode);
    return nodeList;
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) DataNode(org.talend.designer.core.model.process.DataNode) IComponent(org.talend.core.model.components.IComponent) ArrayList(java.util.ArrayList) IElementParameter(org.talend.core.model.process.IElementParameter) EDatabaseTypeName(org.talend.core.database.EDatabaseTypeName) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn)

Example 10 with DataNode

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

the class StatsAndLogsManager method getStatsAndLogsNodes.

public static List<DataNode> getStatsAndLogsNodes(IProcess process) {
    List<DataNode> nodeList = new ArrayList<DataNode>();
    String dbOutput = null;
    boolean dbFlag = ((Boolean) process.getElementParameter(EParameterName.ON_DATABASE_FLAG.getName()).getValue()) && process.getElementParameter(EParameterName.ON_DATABASE_FLAG.getName()).isShow(process.getElementParameters());
    if (!dbFlag) {
        dbOutput = null;
    } else {
        dbOutput = (String) process.getElementParameter(EParameterName.DB_TYPE.getName()).getValue();
        dbOutput = OracleComponentHelper.filterOracleComponentName(dbOutput);
        if (dbOutput == null || dbOutput.equals("")) {
            //$NON-NLS-1$
            dbOutput = null;
            dbFlag = false;
        }
    }
    boolean file = ((Boolean) process.getElementParameter(EParameterName.ON_FILES_FLAG.getName()).getValue()) && process.getElementParameter(EParameterName.ON_FILES_FLAG.getName()).isShow(process.getElementParameters());
    boolean console = ((Boolean) process.getElementParameter(EParameterName.ON_CONSOLE_FLAG.getName()).getValue()) && process.getElementParameter(EParameterName.ON_CONSOLE_FLAG.getName()).isShow(process.getElementParameters());
    if (!file && !dbFlag && !console) {
        return nodeList;
    }
    boolean useStats = ((Boolean) process.getElementParameter(EParameterName.ON_STATCATCHER_FLAG.getName()).getValue()) && process.getElementParameter(EParameterName.ON_STATCATCHER_FLAG.getName()).isShow(process.getElementParameters());
    boolean useLogs = ((Boolean) process.getElementParameter(EParameterName.ON_LOGCATCHER_FLAG.getName()).getValue()) && process.getElementParameter(EParameterName.ON_LOGCATCHER_FLAG.getName()).isShow(process.getElementParameters());
    boolean useMetter = ((Boolean) process.getElementParameter(EParameterName.ON_METERCATCHER_FLAG.getName()).getValue()) && process.getElementParameter(EParameterName.ON_METERCATCHER_FLAG.getName()).isShow(process.getElementParameters());
    String basePath = (String) process.getElementParameter(EParameterName.FILE_PATH.getName()).getValue();
    //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    basePath = basePath.replace("\\", "/") + "+ \"/\" +";
    DataNode connectionNode = null;
    //        String connectionUID = "connectionStatsLogs";//$NON-NLS-1$
    DataNode commitNode = null;
    String connectionUID2;
    IComponent commitComponent = null;
    String subString = null;
    /*
         * maybe, need create every of committing node for log/stat/metter.
         */
    // for bug 10453
    boolean isNotInformixDB = true;
    if (dbFlag) {
        String[] javaDbComponents = StatsAndLogsConstants.DB_OUTPUT_COMPONENTS;
        for (String dbComponent : javaDbComponents) {
            String commitComponentName = null;
            if (OracleComponentHelper.filterOracleConnectionType((String) process.getElementParameter(EParameterName.DB_TYPE.getName()).getValue()).equals(dbComponent)) {
                if (dbComponent.endsWith("Output")) {
                    //$NON-NLS-1$
                    //$NON-NLS-1$
                    subString = dbComponent.substring(0, dbComponent.lastIndexOf("Output"));
                    //$NON-NLS-1$
                    commitComponentName = subString + "Commit";
                } else {
                    //$NON-NLS-1$
                    commitComponentName = "tOracleCommit";
                }
                commitComponent = ComponentsFactoryProvider.getInstance().get(commitComponentName, ComponentCategory.CATEGORY_4_DI.getName());
                if (commitComponentName.indexOf("Informix") != -1) {
                    isNotInformixDB = false;
                }
                if (commitComponent != null) {
                    //$NON-NLS-1$
                    connectionUID2 = CONNECTION_UID + "_Commit";
                    commitNode = new DataNode(commitComponent, connectionUID2);
                    commitNode.setSubProcessStart(true);
                    commitNode.setActivate(true);
                    commitNode.getElementParameter(EParameterName.CONNECTION.getName()).setValue(CONNECTION_UID);
                    IElementParameter elementParameter = commitNode.getElementParameter("CLOSE");
                    if (elementParameter != null) {
                        elementParameter.setValue(Boolean.FALSE);
                    }
                    commitNode.setProcess(process);
                    nodeList.add(commitNode);
                }
            }
        }
    }
    if (useLogs) {
        DataNode logsNode = createLogsNode(file, console, dbOutput);
        if (LanguageManager.getCurrentLanguage().equals(ECodeLanguage.PERL)) {
            //$NON-NLS-1$
            logsNode.getElementParameter("FILENAME").setValue(//$NON-NLS-1$ //$NON-NLS-2$
            "File::Spec->catfile(" + basePath + "," + process.getElementParameter(EParameterName.FILENAME_LOGS.getName()).getValue() + //$NON-NLS-1$
            ")");
        } else {
            //$NON-NLS-1$
            logsNode.getElementParameter("FILENAME").setValue(basePath + process.getElementParameter(EParameterName.FILENAME_LOGS.getName()).getValue());
        }
        if (dbFlag) {
            if (commitNode != null && isNotInformixDB) {
                connectionNode = addConnection(connectionNode, process, CONNECTION_UID, logsNode, nodeList, commitNode);
            } else {
                useNoConnectionComponentDB(logsNode, process, CONNECTION_UID);
            }
            //$NON-NLS-1$
            logsNode.getElementParameter("TABLE").setValue(process.getElementParameter(EParameterName.TABLE_LOGS.getName()).getValue());
        }
        if (file) {
            IElementParameter encodingParameter = process.getElementParameter(EParameterName.ENCODING.getName());
            if (encodingParameter != null) {
                Object value = encodingParameter.getValue();
                if (value != null && !"".equals(value)) {
                    IElementParameter elementParameter = logsNode.getElementParameter(EParameterName.ENCODING.getName());
                    if (elementParameter != null) {
                        String encoding = value.toString();
                        if (!value.toString().startsWith(TalendTextUtils.getQuoteChar())) {
                            encoding = TalendTextUtils.addQuotes(encoding);
                        }
                        elementParameter.setValue(encoding);
                    }
                }
            }
        }
        logsNode.getElementParameter(EParameterName.CATCH_RUNTIME_ERRORS.getName()).setValue(process.getElementParameter(EParameterName.CATCH_RUNTIME_ERRORS.getName()).getValue());
        logsNode.getElementParameter(EParameterName.CATCH_USER_ERRORS.getName()).setValue(process.getElementParameter(EParameterName.CATCH_USER_ERRORS.getName()).getValue());
        logsNode.getElementParameter(EParameterName.CATCH_USER_WARNING.getName()).setValue(process.getElementParameter(EParameterName.CATCH_USER_WARNING.getName()).getValue());
        logsNode.setProcess(process);
        nodeList.add(logsNode);
    }
    if (useStats) {
        DataNode statsNode = createStatsNode(file, console, dbOutput);
        if (LanguageManager.getCurrentLanguage().equals(ECodeLanguage.PERL)) {
            //$NON-NLS-1$
            statsNode.getElementParameter("FILENAME").setValue(//$NON-NLS-1$ //$NON-NLS-2$
            "File::Spec->catfile(" + basePath + "," + process.getElementParameter(EParameterName.FILENAME_STATS.getName()).getValue() + //$NON-NLS-1$
            ")");
        } else {
            //$NON-NLS-1$
            statsNode.getElementParameter("FILENAME").setValue(basePath + process.getElementParameter(EParameterName.FILENAME_STATS.getName()).getValue());
        }
        if (dbFlag) {
            if (commitNode != null && isNotInformixDB) {
                connectionNode = addConnection(connectionNode, process, CONNECTION_UID, statsNode, nodeList, commitNode);
            } else {
                useNoConnectionComponentDB(statsNode, process, CONNECTION_UID);
            }
            //$NON-NLS-1$
            statsNode.getElementParameter("TABLE").setValue(process.getElementParameter(EParameterName.TABLE_STATS.getName()).getValue());
        }
        if (file) {
            IElementParameter encodingParameter = process.getElementParameter(EParameterName.ENCODING.getName());
            if (encodingParameter != null) {
                Object value = encodingParameter.getValue();
                if (value != null && !"".equals(value)) {
                    IElementParameter elementParameter = statsNode.getElementParameter(EParameterName.ENCODING.getName());
                    if (elementParameter != null) {
                        String encoding = value.toString();
                        if (!value.toString().startsWith(TalendTextUtils.getQuoteChar())) {
                            encoding = TalendTextUtils.addQuotes(encoding);
                        }
                        elementParameter.setValue(encoding);
                    }
                }
            }
        }
        statsNode.setProcess(process);
        nodeList.add(statsNode);
    }
    if (useMetter) {
        DataNode meterNode = createMetterNode(file, console, dbOutput);
        if (LanguageManager.getCurrentLanguage().equals(ECodeLanguage.PERL)) {
            //$NON-NLS-1$
            meterNode.getElementParameter("FILENAME").setValue(//$NON-NLS-1$ //$NON-NLS-2$
            "File::Spec->catfile(" + basePath + "," + process.getElementParameter(EParameterName.FILENAME_METTER.getName()).getValue() + //$NON-NLS-1$
            ")");
        } else {
            //$NON-NLS-1$
            meterNode.getElementParameter("FILENAME").setValue(basePath + process.getElementParameter(EParameterName.FILENAME_METTER.getName()).getValue());
        }
        if (dbFlag) {
            if (commitNode != null && isNotInformixDB) {
                connectionNode = addConnection(connectionNode, process, CONNECTION_UID, meterNode, nodeList, commitNode);
            } else {
                useNoConnectionComponentDB(meterNode, process, CONNECTION_UID);
            }
            //$NON-NLS-1$
            meterNode.getElementParameter("TABLE").setValue(process.getElementParameter(EParameterName.TABLE_METER.getName()).getValue());
        }
        if (file) {
            IElementParameter encodingParameter = process.getElementParameter(EParameterName.ENCODING.getName());
            if (encodingParameter != null) {
                Object value = encodingParameter.getValue();
                if (value != null && !"".equals(value)) {
                    IElementParameter elementParameter = meterNode.getElementParameter(EParameterName.ENCODING.getName());
                    if (elementParameter != null) {
                        String encoding = value.toString();
                        if (!value.toString().startsWith(TalendTextUtils.getQuoteChar())) {
                            encoding = TalendTextUtils.addQuotes(encoding);
                        }
                        elementParameter.setValue(encoding);
                    }
                }
            }
        }
        meterNode.setProcess(process);
        nodeList.add(meterNode);
    }
    return nodeList;
}
Also used : DataNode(org.talend.designer.core.model.process.DataNode) IComponent(org.talend.core.model.components.IComponent) ArrayList(java.util.ArrayList) IElementParameter(org.talend.core.model.process.IElementParameter)

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