Search in sources :

Example 56 with ElementParameterType

use of org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType 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 57 with ElementParameterType

use of org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType 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 58 with ElementParameterType

use of org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType 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 59 with ElementParameterType

use of org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType 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 60 with ElementParameterType

use of org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType in project tdi-studio-se by Talend.

the class UpdateTheJobsActionsOnTable method execute.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.core.model.migration.AbstractJobMigrationTask#executeOnProcess(org.talend.core.model.properties.ProcessItem)
     */
@Override
public ExecutionResult execute(Item item) {
    ProcessType process = getProcessType(item);
    if (process == null) {
        return ExecutionResult.NOTHING_TO_DO;
    }
    List<NodeType> nodeList = process.getNode();
    for (NodeType node : nodeList) {
        if (node.getComponentName().indexOf(UpdateTheJobsActionsOnTable.T_ORACLE_OUTPUT) != -1) {
            for (ElementParameterType elementParameterType : (List<ElementParameterType>) node.getElementParameter()) {
                if (UpdateTheJobsActionsOnTable.CLEAR_TABLE.equals(elementParameterType.getName())) {
                    if ("true".equals(elementParameterType.getValue())) {
                        //$NON-NLS-1$
                        UpdateTheJobsActionsOnTable.isClear = true;
                        return ExecutionResult.SUCCESS_NO_ALERT;
                    }
                }
            }
        }
    }
    return ExecutionResult.NOTHING_TO_DO;
}
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) List(java.util.List)

Aggregations

ElementParameterType (org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType)197 NodeType (org.talend.designer.core.model.utils.emf.talendfile.NodeType)126 ProcessType (org.talend.designer.core.model.utils.emf.talendfile.ProcessType)114 PersistenceException (org.talend.commons.exception.PersistenceException)86 IComponentConversion (org.talend.core.model.components.conversions.IComponentConversion)85 IComponentFilter (org.talend.core.model.components.filters.IComponentFilter)83 NameComponentFilter (org.talend.core.model.components.filters.NameComponentFilter)83 EList (org.eclipse.emf.common.util.EList)40 ElementValueType (org.talend.designer.core.model.utils.emf.talendfile.ElementValueType)28 ProxyRepositoryFactory (org.talend.core.repository.model.ProxyRepositoryFactory)25 List (java.util.List)22 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)19 ArrayList (java.util.ArrayList)16 ProcessItem (org.talend.core.model.properties.ProcessItem)16 ParametersType (org.talend.designer.core.model.utils.emf.talendfile.ParametersType)15 ConnectionType (org.talend.designer.core.model.utils.emf.talendfile.ConnectionType)13 JobletProcessItem (org.talend.core.model.properties.JobletProcessItem)9 HashMap (java.util.HashMap)7 IOException (java.io.IOException)6 IElementParameter (org.talend.core.model.process.IElementParameter)6