Search in sources :

Example 96 with IComponentFilter

use of org.talend.core.model.components.filters.IComponentFilter in project tdi-studio-se by Talend.

the class ChangeHadoopVersionsOfReferenceComponentsMigrationTask method execute.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.core.model.migration.AbstractItemMigrationTask#execute(org.talend.core.model.properties.Item)
     */
@Override
public ExecutionResult execute(Item item) {
    ProcessType processType = getProcessType(item);
    if (processType == null) {
        return ExecutionResult.NOTHING_TO_DO;
    }
    String[] componentsName = new String[] { //$NON-NLS-1$
    "tPigLoad", //$NON-NLS-1$
    "tHDFSCompare", //$NON-NLS-1$
    "tHDFSConnection", //$NON-NLS-1$
    "tHDFSCopy", //$NON-NLS-1$
    "tHDFSDelete", //$NON-NLS-1$
    "tHDFSExist", //$NON-NLS-1$
    "tHDFSGet", //$NON-NLS-1$
    "tHDFSInput", //$NON-NLS-1$
    "tHDFSList", //$NON-NLS-1$
    "tHDFSOutput", //$NON-NLS-1$
    "tHDFSProperties", //$NON-NLS-1$
    "tHDFSPut", //$NON-NLS-1$
    "tHDFSRename", //$NON-NLS-1$
    "tHDFSRowCount", //$NON-NLS-1$
    "tPigStoreResult", //$NON-NLS-1$
    "tSqoopExport", //$NON-NLS-1$
    "tSqoopImport", //$NON-NLS-1$
    "tSqoopImportAllTables", //$NON-NLS-1$
    "tGenKeyHadoop", //$NON-NLS-1$ 
    "tMatchGroupHadoop" };
    try {
        for (String element : componentsName) {
            IComponentFilter filter = new NameComponentFilter(element);
            ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(new IComponentConversion() {

                @Override
                public void transform(NodeType node) {
                    //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 
                    String[] params = { "PIG_VERSION", "DB_VERSION", /* "MR_VERSION", */
                    "HBASE_VERSION" };
                    ElementParameterType ept = null;
                    for (String param : params) {
                        ept = ComponentUtilities.getNodeProperty(node, param);
                        if (ept != null) {
                            setValue(node, ept, param);
                            break;
                        }
                    }
                }
            }));
        }
        return ExecutionResult.SUCCESS_NO_ALERT;
    } catch (java.lang.Exception e) {
        ExceptionHandler.process(e);
        return ExecutionResult.FAILURE;
    }
}
Also used : ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) IComponentFilter(org.talend.core.model.components.filters.IComponentFilter) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) NameComponentFilter(org.talend.core.model.components.filters.NameComponentFilter) IComponentConversion(org.talend.core.model.components.conversions.IComponentConversion)

Example 97 with IComponentFilter

use of org.talend.core.model.components.filters.IComponentFilter in project tdi-studio-se by Talend.

the class ChangeJDBCDriverJarTypeForFeature12879 method execute.

@Override
public ExecutionResult execute(Item item) {
    ProcessType processType = getProcessType(item);
    if (getProject().getLanguage() != ECodeLanguage.JAVA || processType == null) {
        return ExecutionResult.NOTHING_TO_DO;
    }
    String[] componentsName = new String[] { "tJDBCConnection", "tJDBCInput", "tJDBCOutput", "tJDBCRow", "tJDBCSP", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
    "tELTJDBCMap" };
    IComponentConversion changeJDBCDriverJarType = new IComponentConversion() {

        public void transform(NodeType node) {
            ElementParameterType driverType = ComponentUtilities.getNodeProperty(node, "DRIVER_JAR");
            if (driverType != null) {
                String value = driverType.getValue();
                if (value != null && !"".equals(value)) {
                    value = TalendTextUtils.removeQuotes(value);
                }
                driverType.setField("TABLE");
                driverType.setValue(null);
                ElementValueType valueType = TalendFileFactory.eINSTANCE.createElementValueType();
                valueType.setElementRef("JAR_NAME");
                valueType.setValue(value);
                driverType.getElementValue().add(valueType);
            }
        }
    };
    for (String name : componentsName) {
        //$NON-NLS-1$
        IComponentFilter filter = new NameComponentFilter(name);
        try {
            ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(changeJDBCDriverJarType));
        } catch (PersistenceException e) {
            // TODO Auto-generated catch block
            ExceptionHandler.process(e);
            return ExecutionResult.FAILURE;
        }
    }
    return ExecutionResult.SUCCESS_WITH_ALERT;
}
Also used : ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) ElementValueType(org.talend.designer.core.model.utils.emf.talendfile.ElementValueType) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) IComponentFilter(org.talend.core.model.components.filters.IComponentFilter) PersistenceException(org.talend.commons.exception.PersistenceException) NameComponentFilter(org.talend.core.model.components.filters.NameComponentFilter) IComponentConversion(org.talend.core.model.components.conversions.IComponentConversion)

Example 98 with IComponentFilter

use of org.talend.core.model.components.filters.IComponentFilter in project tdi-studio-se by Talend.

the class ChangeMongoDBMinimalVersion method execute.

@Override
public ExecutionResult execute(Item item) {
    ProcessType processType = getProcessType(item);
    IComponentFilter filterConnection = new NameComponentFilter("tMongoDBConnection");
    IComponentFilter filterInput = new NameComponentFilter("tMongoDBInput");
    IComponentFilter filterOutput = new NameComponentFilter("tMongoDBOutput");
    IComponentFilter filterRow = new NameComponentFilter("tMongoDBRow");
    IComponentFilter filterWriteConf = new NameComponentFilter("tMongoDBWriteConf");
    try {
        ModifyComponentsAction.searchAndModify(item, processType, filterConnection, Arrays.<IComponentConversion>asList(new ChangeDeprecatedVersion()));
        ModifyComponentsAction.searchAndModify(item, processType, filterInput, Arrays.<IComponentConversion>asList(new ChangeDeprecatedVersion()));
        ModifyComponentsAction.searchAndModify(item, processType, filterOutput, Arrays.<IComponentConversion>asList(new ChangeDeprecatedVersion()));
        ModifyComponentsAction.searchAndModify(item, processType, filterRow, Arrays.<IComponentConversion>asList(new ChangeDeprecatedVersion()));
        ModifyComponentsAction.searchAndModify(item, processType, filterWriteConf, Arrays.<IComponentConversion>asList(new ChangeDeprecatedVersion()));
    } catch (PersistenceException e) {
        ExceptionHandler.process(e);
        return ExecutionResult.FAILURE;
    }
    return ExecutionResult.SUCCESS_NO_ALERT;
// return ExecutionResult.SUCCESS_NO_ALERT;
}
Also used : ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) IComponentFilter(org.talend.core.model.components.filters.IComponentFilter) PersistenceException(org.talend.commons.exception.PersistenceException) NameComponentFilter(org.talend.core.model.components.filters.NameComponentFilter)

Example 99 with IComponentFilter

use of org.talend.core.model.components.filters.IComponentFilter in project tdi-studio-se by Talend.

the class ChangeMysqlJarReference4MysqlComponents method execute.

@Override
public ExecutionResult execute(Item item) {
    ProcessType processType = getProcessType(item);
    String[] mysqlCompNames = { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
    "tAmazonMysqlConnection", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
    "tAmazonMysqlInput", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
    "tAmazonMysqlOutput", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
    "tAmazonMysqlRow", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
    "tCreateTable", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
    "tELTMysqlMap", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
    "tMondrianInput", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
    "tMysqlBulkExec", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
    "tMysqlConnection", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
    "tMysqlInput", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
    "tMysqlOutput", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
    "tMysqlOutputBulkExec", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
    "tMysqlRow", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
    "tMysqlSCD", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
    "tMysqlSCDELT", "tMysqlSP", "tMySQLInvalidRows", "tMySQLValidRows", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
    "tMysqlCDC" };
    IComponentConversion changeOracleDriverJarType = new IComponentConversion() {

        public void transform(NodeType node) {
            if (node == null) {
                return;
            }
            if ("tCreateTable".equals(node.getComponentName())) {
                //$NON-NLS-1$
                //$NON-NLS-1$
                ElementParameterType dbVersion = ComponentUtilities.getNodeProperty(node, "DB_MYSQL_VERSION");
                if (dbVersion != null) {
                    String jarValue = dbVersion.getValue();
                    if ("mysql-connector-java-5.1.0-bin.jar".equalsIgnoreCase(jarValue)) {
                        //$NON-NLS-1$
                        //$NON-NLS-1$
                        dbVersion.setValue("MYSQL_5");
                    } else if ("mysql-connector-java-3.1.14-bin.jar".equalsIgnoreCase(jarValue)) {
                        //$NON-NLS-1$
                        //$NON-NLS-1$
                        dbVersion.setValue("MYSQL_4");
                    }
                }
            }
            //$NON-NLS-1$
            ElementParameterType dbVersion = ComponentUtilities.getNodeProperty(node, "DB_VERSION");
            if (dbVersion != null) {
                String jarValue = dbVersion.getValue();
                if ("mysql-connector-java-5.1.0-bin.jar".equalsIgnoreCase(jarValue)) {
                    //$NON-NLS-1$
                    //$NON-NLS-1$
                    dbVersion.setValue("MYSQL_5");
                } else if ("mysql-connector-java-3.1.14-bin.jar".equalsIgnoreCase(jarValue)) {
                    //$NON-NLS-1$
                    //$NON-NLS-1$
                    dbVersion.setValue("MYSQL_4");
                }
            }
        }
    };
    for (String name : mysqlCompNames) {
        IComponentFilter filter = new NameComponentFilter(name);
        try {
            ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(changeOracleDriverJarType));
        } catch (PersistenceException e) {
            // TODO Auto-generated catch block
            ExceptionHandler.process(e);
            return ExecutionResult.FAILURE;
        }
    }
    return ExecutionResult.SUCCESS_NO_ALERT;
}
Also used : ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) IComponentFilter(org.talend.core.model.components.filters.IComponentFilter) PersistenceException(org.talend.commons.exception.PersistenceException) NameComponentFilter(org.talend.core.model.components.filters.NameComponentFilter) IComponentConversion(org.talend.core.model.components.conversions.IComponentConversion)

Example 100 with IComponentFilter

use of org.talend.core.model.components.filters.IComponentFilter in project tdi-studio-se by Talend.

the class ChangeOptionDefaultValueForFileArchive method execute.

@Override
public ExecutionResult execute(Item item) {
    ProcessType processType = getProcessType(item);
    if (getProject().getLanguage() != ECodeLanguage.JAVA || processType == null) {
        return ExecutionResult.NOTHING_TO_DO;
    }
    String[] componentsName = new String[] { "tFileArchive", "tFileUnarchive" };
    IComponentConversion changeJDBCDriverJarType = new IComponentConversion() {

        public void transform(NodeType node) {
            if ("tFileArchive".equals(node.getComponentName())) {
                ElementParameterType encryptMethod = ComponentUtilities.getNodeProperty(node, "ENCRYPT_METHOD");
                if (encryptMethod != null) {
                    if ("DEFAULT".equals(encryptMethod.getValue())) {
                        ComponentUtilities.setNodeValue(node, "ENCRYPT_METHOD", "JAVA_ENCRYPT");
                    }
                    if ("AES256".equals(encryptMethod.getValue())) {
                        ComponentUtilities.setNodeValue(node, "ENCRYPT_METHOD", "ENC_METHOD_AES");
                    }
                }
            }
            if ("tFileUnarchive".equals(node.getComponentName())) {
                ElementParameterType encryptMethod = ComponentUtilities.getNodeProperty(node, "DECRYPT_METHOD");
                if (encryptMethod != null) {
                    if ("DEFAULT".equals(encryptMethod.getValue())) {
                        ComponentUtilities.setNodeValue(node, "DECRYPT_METHOD", "JAVA_DECRYPT");
                    }
                    if ("AES256".equals(encryptMethod.getValue())) {
                        ComponentUtilities.setNodeValue(node, "DECRYPT_METHOD", "ZIP4J_DECRYPT");
                    }
                }
            }
        }
    };
    for (String name : componentsName) {
        //$NON-NLS-1$
        IComponentFilter filter = new NameComponentFilter(name);
        try {
            ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(changeJDBCDriverJarType));
        } catch (PersistenceException e) {
            ExceptionHandler.process(e);
            return ExecutionResult.FAILURE;
        }
    }
    return ExecutionResult.SUCCESS_WITH_ALERT;
}
Also used : ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) IComponentFilter(org.talend.core.model.components.filters.IComponentFilter) PersistenceException(org.talend.commons.exception.PersistenceException) NameComponentFilter(org.talend.core.model.components.filters.NameComponentFilter) IComponentConversion(org.talend.core.model.components.conversions.IComponentConversion)

Aggregations

IComponentFilter (org.talend.core.model.components.filters.IComponentFilter)154 ProcessType (org.talend.designer.core.model.utils.emf.talendfile.ProcessType)153 IComponentConversion (org.talend.core.model.components.conversions.IComponentConversion)151 NameComponentFilter (org.talend.core.model.components.filters.NameComponentFilter)145 NodeType (org.talend.designer.core.model.utils.emf.talendfile.NodeType)111 ElementParameterType (org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType)84 PersistenceException (org.talend.commons.exception.PersistenceException)78 ElementValueType (org.talend.designer.core.model.utils.emf.talendfile.ElementValueType)15 RenameComponentConversion (org.talend.core.model.components.conversions.RenameComponentConversion)12 ArrayList (java.util.ArrayList)10 RemovePropertyComponentConversion (org.talend.core.model.components.conversions.RemovePropertyComponentConversion)9 List (java.util.List)7 PropertyComponentFilter (org.talend.core.model.components.filters.PropertyComponentFilter)6 ConnectionType (org.talend.designer.core.model.utils.emf.talendfile.ConnectionType)5 HashMap (java.util.HashMap)3 EConnectionType (org.talend.core.model.process.EConnectionType)3 MetadataType (org.talend.designer.core.model.utils.emf.talendfile.MetadataType)3 ComponentProperties (org.talend.components.api.properties.ComponentProperties)2 AddPropertyCSVOptionConversion (org.talend.core.model.components.conversions.AddPropertyCSVOptionConversion)2 AddPropertyLoopTypeConversion (org.talend.core.model.components.conversions.AddPropertyLoopTypeConversion)2