Search in sources :

Example 51 with IComponentConversion

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

the class ChangeLogLevel4tRedshiftInput 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;
    }
    //$NON-NLS-1$
    String[] componentsName = new String[] { "tRedshiftInput" };
    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$
                    ElementParameterType ept = ComponentUtilities.getNodeProperty(node, "LOG_LEVEL");
                    if (ept == null) {
                        return;
                    }
                    String value = ept.getValue();
                    if (value == null) {
                        return;
                    }
                    if (Integer.parseInt(value) > 2) {
                        //$NON-NLS-1$//$NON-NLS-2$
                        ComponentUtilities.setNodeValue(node, "LOG_LEVEL", "2");
                    }
                }
            }));
        }
        return ExecutionResult.SUCCESS_NO_ALERT;
    } catch (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 52 with IComponentConversion

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

the class ChangeMappingParameter4Redshift method execute.

@Override
public ExecutionResult execute(Item item) {
    final ProcessType processType = getProcessType(item);
    //$NON-NLS-1$ //$NON-NLS-2$
    String[] compNames = { "tRedshiftInput", "tRedshiftOutput" };
    IComponentConversion changeDBName4Hive = new IComponentConversion() {

        public void transform(NodeType node) {
            if (node == null) {
                return;
            }
            //$NON-NLS-1$
            ElementParameterType dbId = ComponentUtilities.getNodeProperty(node, "MAPPING");
            if (dbId == null) {
                return;
            }
            //$NON-NLS-1$
            dbId.setValue("redshift_id");
        }
    };
    for (String name : compNames) {
        IComponentFilter filter = new NameComponentFilter(name);
        try {
            ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(changeDBName4Hive));
        } 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 53 with IComponentConversion

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

the class ChangeOptionDefaultValueFortNormalize method execute.

@Override
public ExecutionResult execute(Item item) {
    ProcessType processType = getProcessType(item);
    IComponentFilter filter = new NameComponentFilter("tNormalize");
    try {
        ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(new IComponentConversion() {

            public void transform(NodeType node) {
                if (ComponentUtilities.getNodeProperty(node, "DISCARD_TRAILING_EMPTY_STR") == null) {
                    ComponentUtilities.addNodeProperty(node, "DISCARD_TRAILING_EMPTY_STR", "CHECK");
                    ElementParameterType useCSVOption = ComponentUtilities.getNodeProperty(node, "CSV_OPTION");
                    if (useCSVOption != null && "false".equals(useCSVOption.getValue())) {
                        ComponentUtilities.getNodeProperty(node, "DISCARD_TRAILING_EMPTY_STR").setValue("true");
                    }
                }
            }
        }));
    } catch (PersistenceException e) {
        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) IComponentFilter(org.talend.core.model.components.filters.IComponentFilter) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) PersistenceException(org.talend.commons.exception.PersistenceException) NameComponentFilter(org.talend.core.model.components.filters.NameComponentFilter) IComponentConversion(org.talend.core.model.components.conversions.IComponentConversion)

Example 54 with IComponentConversion

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

the class ChangeOracleJarName4OracleComponents method execute.

@Override
public ExecutionResult execute(Item item) {
    ProcessType processType = getProcessType(item);
    String[] oracleCompNames = { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
    "tOracleBulkExec", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
    "tOracleClose", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
    "tOracleCommit", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
    "tOracleConnection", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
    "tOracleInput", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
    "tOracleOutput", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
    "tOracleOutputBulk", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
    "tOracleOutputBulkExec", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
    "tOracleRollback", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
    "tOracleRow", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
    "tOracleSCD", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
    "tOracleSCDELT", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
    "tOracleSP", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
    "tOracleTableList", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
    "tAmazonOracleClose", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    "tAmazonOracleCommit", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    "tAmazonOracleConnection", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    "tAmazonOracleInput", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
    "tAmazonOracleOutput", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
    "tAmazonOracleRollback", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
    "tAmazonOracleRow", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
    "tMondrianInput", //$NON-NLS-1$ //$NON-NLS-2$
    "tCreateTable", //$NON-NLS-1$ //$NON-NLS-2$
    "tOracleInvalidRows", "tOracleValidRows", "tELTOracleMap", "tOracleCDC", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
    "tOracleSCDELT" };
    IComponentConversion changeOracleDriverJarType = new IComponentConversion() {

        public void transform(NodeType node) {
            //$NON-NLS-1$
            ElementParameterType dbVersion = ComponentUtilities.getNodeProperty(node, "DB_VERSION");
            if (dbVersion != null) {
                String jarValue = dbVersion.getValue();
                if ("ojdbc6-11g.jar".equalsIgnoreCase(jarValue)) {
                    //$NON-NLS-1$
                    //$NON-NLS-1$
                    dbVersion.setValue("ojdbc6.jar");
                } else if ("ojdbc5-11g.jar".equalsIgnoreCase(jarValue)) {
                    //$NON-NLS-1$
                    //$NON-NLS-1$
                    dbVersion.setValue("ojdbc5.jar");
                } else if ("ojdbc14-10g.jar".equalsIgnoreCase(jarValue)) {
                    //$NON-NLS-1$
                    //$NON-NLS-1$
                    dbVersion.setValue("ojdbc14.jar");
                } else if ("ojdbc14-9i.jar".equalsIgnoreCase(jarValue)) {
                //$NON-NLS-1$
                // db_version.setValue("ojdbc14-9i.jar");
                } else if ("ojdbc12-8i.jar".equalsIgnoreCase(jarValue)) {
                    //$NON-NLS-1$
                    //$NON-NLS-1$
                    dbVersion.setValue("ojdbc12.jar");
                }
            }
        }
    };
    for (String name : oracleCompNames) {
        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 55 with IComponentConversion

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

the class ChangeValueTDIBug19870 method execute.

/*
     * (non-Javadoc)
     * 
     * @seeorg.talend.core.model.migration.AbstractJobMigrationTask#executeOnProcess(org.talend.core.model.properties.
     * ProcessItem)
     */
@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[] { "tHDFSOutput" };
    try {
        for (int i = 0; i < componentsName.length; i++) {
            IComponentFilter filter = new NameComponentFilter(componentsName[i]);
            ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(new IComponentConversion() {

                public void transform(NodeType node) {
                    if (ComponentUtilities.getNodeProperty(node, "FILE_ACTION") == null || "false".equals(ComponentUtilities.getNodeProperty(node, "FILE_ACTION").getValue())) {
                        ComponentUtilities.getNodeProperty(node, "FILE_ACTION").setValue("CREATE");
                    } else if ("true".equals(ComponentUtilities.getNodeProperty(node, "FILE_ACTION").getValue())) {
                        ComponentUtilities.getNodeProperty(node, "FILE_ACTION").setValue("OVERWRITE");
                    }
                }
            }));
        }
        return ExecutionResult.SUCCESS_NO_ALERT;
    } catch (Exception e) {
        ExceptionHandler.process(e);
        return ExecutionResult.FAILURE;
    }
}
Also used : 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)

Aggregations

IComponentConversion (org.talend.core.model.components.conversions.IComponentConversion)154 ProcessType (org.talend.designer.core.model.utils.emf.talendfile.ProcessType)154 IComponentFilter (org.talend.core.model.components.filters.IComponentFilter)150 NameComponentFilter (org.talend.core.model.components.filters.NameComponentFilter)142 NodeType (org.talend.designer.core.model.utils.emf.talendfile.NodeType)111 ElementParameterType (org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType)85 PersistenceException (org.talend.commons.exception.PersistenceException)77 ElementValueType (org.talend.designer.core.model.utils.emf.talendfile.ElementValueType)15 RenameComponentConversion (org.talend.core.model.components.conversions.RenameComponentConversion)12 ArrayList (java.util.ArrayList)11 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