Search in sources :

Example 96 with ElementParameterType

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

the class ChangeShareIdentityDefaultValueMigrationTaskIssue9519 method execute.

public ExecutionResult execute(Item item) {
    ProcessType processType = getProcessType(item);
    if (getProject().getLanguage() != ECodeLanguage.JAVA || processType == null) {
        return ExecutionResult.NOTHING_TO_DO;
    }
    //$NON-NLS-1$ 
    String[] componentsName = new String[] { "tMSSqlConnection" };
    for (String name : componentsName) {
        //$NON-NLS-1$
        IComponentFilter filter = new NameComponentFilter(name);
        try {
            ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(new IComponentConversion() {

                public void transform(NodeType node) {
                    // TODO Auto-generated method stub
                    //$NON-NLS-1$
                    ElementParameterType propertyShareIdentitySetting = ComponentUtilities.getNodeProperty(node, "SHARE_IDENTITY_SETTING");
                    if (propertyShareIdentitySetting == null) {
                        //$NON-NLS-1$
                        //$NON-NLS-1$ //$NON-NLS-2$
                        ComponentUtilities.addNodeProperty(node, "SHARE_IDENTITY_SETTING", "CHECK");
                        //$NON-NLS-1$ //$NON-NLS-2$
                        ComponentUtilities.setNodeValue(node, "SHARE_IDENTITY_SETTING", "true");
                    }
                }
            }));
        } 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) 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 97 with ElementParameterType

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

the class ChangeSpecifyKeysAndColumnsFortCassandraInput method execute.

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

            public void transform(NodeType node) {
                ElementParameterType specifyKeys = ComponentUtilities.getNodeProperty(node, "SPECIFY_KEYS");
                ElementParameterType specifyColumns = ComponentUtilities.getNodeProperty(node, "SPECIFY_COLUMNS");
                ElementParameterType columns = ComponentUtilities.getNodeProperty(node, "SUPER_COLUMN_KEYS");
                ElementParameterType columnStart = ComponentUtilities.getNodeProperty(node, "COLUMN_START");
                ElementParameterType columnEnd = ComponentUtilities.getNodeProperty(node, "COLUMN_END");
                ElementParameterType columnLimit = ComponentUtilities.getNodeProperty(node, "COLUMN_LIMIT");
                ElementParameterType columnFamilyType = ComponentUtilities.getNodeProperty(node, "COLUMN_FAMILY_TYPE");
                ElementParameterType keyStart = ComponentUtilities.getNodeProperty(node, "KEY_START");
                ElementParameterType keyEnd = ComponentUtilities.getNodeProperty(node, "KEY_END");
                ElementParameterType count = ComponentUtilities.getNodeProperty(node, "COUNT");
                if (specifyKeys == null && specifyColumns == null && columnStart == null && columnEnd == null && columns != null && columnLimit == null && keyStart != null && keyEnd != null && count != null) {
                    ComponentUtilities.addNodeProperty(node, "SPECIFY_KEYS", "CHECK");
                    ComponentUtilities.getNodeProperty(node, "SPECIFY_KEYS").setValue("true");
                    ComponentUtilities.addNodeProperty(node, "SPECIFY_COLUMNS", "CHECK");
                    if ("SUPER".equals(columnFamilyType.getValue()) && (!"".equals(columns.getValue())) && (!"\"\"".equals(columns.getValue()))) {
                        ComponentUtilities.getNodeProperty(node, "SPECIFY_COLUMNS").setValue("true");
                    }
                    ComponentUtilities.addNodeProperty(node, "COLUMNS", "TEXT");
                    ComponentUtilities.removeNodeProperty(node, "SUPER_COLUMN_KEYS");
                    ComponentUtilities.getNodeProperty(node, "COLUMNS").setValue(columns.getValue());
                    ComponentUtilities.addNodeProperty(node, "COLUMN_START", "TEXT");
                    ComponentUtilities.getNodeProperty(node, "COLUMN_START").setValue(keyStart.getValue());
                    ComponentUtilities.getNodeProperty(node, "KEY_START").setValue("\"\"");
                    ComponentUtilities.addNodeProperty(node, "COLUMN_END", "TEXT");
                    ComponentUtilities.getNodeProperty(node, "COLUMN_END").setValue(keyEnd.getValue());
                    ComponentUtilities.getNodeProperty(node, "KEY_END").setValue("\"\"");
                    ComponentUtilities.addNodeProperty(node, "COLUMN_LIMIT", "TEXT");
                    ComponentUtilities.getNodeProperty(node, "COLUMN_LIMIT").setValue(count.getValue());
                }
            }
        }));
    } 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 98 with ElementParameterType

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

the class ChangeReadByParameter4tFileInputJSON method execute.

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

        public void transform(NodeType node) {
            if (node == null) {
                return;
            }
            //$NON-NLS-1$
            ElementParameterType originalElement = ComponentUtilities.getNodeProperty(node, "READBYXPATH");
            if (originalElement == null) {
                return;
            }
            String content = originalElement.getValue();
            if (content == null) {
                return;
            }
            ComponentUtilities.addNodeProperty(node, "READ_BY", "CLOSED_LIST");
            if ("false".equals(content)) {
                ComponentUtilities.setNodeValue(node, "READ_BY", "JSONPATH_WITHOUTPUT_LOOP");
            } else {
                //read by xpath
                ComponentUtilities.setNodeValue(node, "READ_BY", "XPATH");
            }
        }
    };
    for (String name : compNames) {
        IComponentFilter filter = new NameComponentFilter(name);
        try {
            ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(action));
        } 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 99 with ElementParameterType

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

the class ChangeOracleJarName4OracleComponentsByDB_VERSION 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$ //$NON-NLS-6$
    "tOracleOutput", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
    "tOracleOutputBulk", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
    "tOracleOutputBulkExec", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
    "tOracleRollback", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
    "tOracleRow", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
    "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$ //$NON-NLS-4$ //$NON-NLS-5$
    "tAmazonOracleCommit", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
    "tAmazonOracleConnection", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
    "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$ //$NON-NLS-3$ //$NON-NLS-4$
    "tCreateTable", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
    "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.jar".equalsIgnoreCase(jarValue)) {
                    //$NON-NLS-1$
                    //$NON-NLS-1$
                    dbVersion.setValue("ORACLE_11-6");
                } else if ("ojdbc5.jar".equalsIgnoreCase(jarValue)) {
                    //$NON-NLS-1$
                    //$NON-NLS-1$
                    dbVersion.setValue("ORACLE_11");
                } else if ("ojdbc14.jar".equalsIgnoreCase(jarValue)) {
                    //$NON-NLS-1$
                    //$NON-NLS-1$
                    dbVersion.setValue("ORACLE_10");
                } else if ("ojdbc14-9i.jar".equalsIgnoreCase(jarValue)) {
                    //$NON-NLS-1$
                    //$NON-NLS-1$
                    dbVersion.setValue("ORACLE_9");
                } else if ("ojdbc12.jar".equalsIgnoreCase(jarValue)) {
                    //$NON-NLS-1$
                    //$NON-NLS-1$
                    dbVersion.setValue("ORACLE_8");
                }
            }
        }
    };
    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 100 with ElementParameterType

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

the class ChangeOracleJarName4OracleDriver method execute.

@Override
public ExecutionResult execute(Item item) {
    ProcessType processType = getProcessType(item);
    String[] compNames = { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
    "tELTJDBCMap", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
    "tJDBCConnection", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
    "tJDBCInput", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
    "tJDBCOutput", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
    "tJDBCRow", "tJDBCSP", //$NON-NLS-1$ //$NON-NLS-2$
    "tLibraryLoad" };
    IComponentConversion changeOracleDriverJarType = new IComponentConversion() {

        public void transform(NodeType node) {
            if ("tLibraryLoad".equals(node.getComponentName())) {
                //$NON-NLS-1$
                //$NON-NLS-1$
                ElementParameterType moduleLib = ComponentUtilities.getNodeProperty(node, "LIBRARY");
                if (moduleLib != null) {
                    moduleLib.setValue(convert(moduleLib.getValue()));
                }
                //$NON-NLS-1$
                ElementParameterType hotLibs = ComponentUtilities.getNodeProperty(node, "HOTLIBS");
                if (hotLibs != null) {
                    for (Object element : hotLibs.getElementValue()) {
                        if (element == null) {
                            continue;
                        }
                        ElementValueType valueType = (ElementValueType) element;
                        if ("LIBPATH".equals(valueType.getElementRef())) {
                            //$NON-NLS-1$
                            valueType.setValue(convert(valueType.getValue()));
                        }
                    }
                }
            } else {
                //$NON-NLS-1$
                ElementParameterType driverJars = ComponentUtilities.getNodeProperty(node, "DRIVER_JAR");
                if (driverJars != null) {
                    for (Object element : driverJars.getElementValue()) {
                        if (element == null) {
                            continue;
                        }
                        ElementValueType valueType = (ElementValueType) element;
                        if ("JAR_NAME".equals(valueType.getElementRef())) {
                            //$NON-NLS-1$
                            valueType.setValue(convert2(valueType.getValue()));
                        }
                    }
                }
            }
        }

        /**
             * convert the string value that contain double quote text closure.
             * @param source
             * @return
             */
        String convert(String source) {
            if ("\"ojdbc6-11g.jar\"".equalsIgnoreCase(source)) {
                //$NON-NLS-1$
                return "\"ojdbc6.jar\"";
            } else if ("\"ojdbc5-11g.jar\"".equalsIgnoreCase(source)) {
                //$NON-NLS-1$
                return "\"ojdbc5.jar\"";
            } else if ("\"ojdbc14-10g.jar\"".equalsIgnoreCase(source)) {
                //$NON-NLS-1$
                return "\"ojdbc14.jar\"";
            } else if ("\"ojdbc12-8i.jar\"".equalsIgnoreCase(source)) {
                //$NON-NLS-1$
                return "\"ojdbc12.jar\"";
            }
            return source;
        }

        /**
             * convert the string value that not contain double quote text closure.
             * @param source
             * @return
             */
        String convert2(String source) {
            if ("ojdbc6-11g.jar".equalsIgnoreCase(source)) {
                //$NON-NLS-1$
                return "ojdbc6.jar";
            } else if ("ojdbc5-11g.jar".equalsIgnoreCase(source)) {
                //$NON-NLS-1$
                return "ojdbc5.jar";
            } else if ("ojdbc14-10g.jar".equalsIgnoreCase(source)) {
                //$NON-NLS-1$
                return "ojdbc14.jar";
            } else if ("ojdbc12-8i.jar".equalsIgnoreCase(source)) {
                //$NON-NLS-1$
                return "ojdbc12.jar";
            }
            return source;
        }
    };
    for (String name : compNames) {
        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) 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)

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