Search in sources :

Example 21 with ElementValueType

use of org.talend.designer.core.model.utils.emf.talendfile.ElementValueType 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)

Example 22 with ElementValueType

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

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

the class SqlTemplateParameterRelationshipHandler method collect.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.core.model.relationship.AbstractParameterRelationshipHandler#collect(java.util.Map,
     * java.util.Map)
     */
@Override
protected Set<Relation> collect(Map<String, ElementParameterType> parametersMap, Map<?, ?> options) {
    Set<Relation> relationSet = new HashSet<Relation>();
    //$NON-NLS-1$
    ElementParameterType sqlpatternParamType = parametersMap.get("SQLPATTERN_VALUE");
    // only for SQL Patterns
    if (sqlpatternParamType != null) {
        for (Object o3 : sqlpatternParamType.getElementValue()) {
            if (o3 instanceof ElementValueType && "SQLPATTERNLIST".equals(((ElementValueType) o3).getElementRef())) {
                //$NON-NLS-1$
                Relation addedRelation = new Relation();
                addedRelation.setId(((ElementValueType) o3).getValue());
                addedRelation.setType(RelationshipItemBuilder.SQLPATTERN_RELATION);
                addedRelation.setVersion(RelationshipItemBuilder.LATEST_VERSION);
                relationSet.add(addedRelation);
            }
        }
    }
    return relationSet;
}
Also used : ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) Relation(org.talend.core.model.relationship.Relation) ElementValueType(org.talend.designer.core.model.utils.emf.talendfile.ElementValueType) HashSet(java.util.HashSet)

Example 24 with ElementValueType

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

the class UpgradetDenormalizeMigrationTask method execute.

public ExecutionResult execute(Item item) {
    ProcessType processType = getProcessType(item);
    if (getProject().getLanguage() != ECodeLanguage.JAVA || processType == null) {
        return ExecutionResult.NOTHING_TO_DO;
    }
    try {
        //$NON-NLS-1$
        IComponentFilter filter1 = new NameComponentFilter("tDenormalize");
        IComponentConversion conversion = new IComponentConversion() {

            public void transform(NodeType node) {
                List<ElementValueType> values = new ArrayList<ElementValueType>();
                TalendFileFactory fileFact = TalendFileFactory.eINSTANCE;
                MetadataType object = (MetadataType) node.getMetadata().get(0);
                //$NON-NLS-1$
                String delimiterValue = ComponentUtilities.getNodePropertyValue(node, "DELIMITER");
                //$NON-NLS-1$
                String mergeValue = ComponentUtilities.getNodePropertyValue(node, "MERGE");
                //$NON-NLS-1$
                ElementParameterType p = ComponentUtilities.getNodeProperty(node, "GROUPS");
                if (p != null) {
                    EList<ElementValueType> es = p.getElementValue();
                    List<String> groups = new ArrayList<String>();
                    for (ElementValueType e : es) {
                        if (e.getElementRef().equals("INPUT_COLUMN")) {
                            //$NON-NLS-1$
                            groups.add(e.getValue());
                        }
                    }
                    for (Object o : object.getColumn()) {
                        ColumnType tagada = (ColumnType) o;
                        if (groups.contains(tagada.getName())) {
                            continue;
                        }
                        ElementValueType elementValue = fileFact.createElementValueType();
                        //$NON-NLS-1$
                        elementValue.setElementRef("INPUT_COLUMN");
                        elementValue.setValue(tagada.getName());
                        values.add(elementValue);
                        ElementValueType elementValue2 = fileFact.createElementValueType();
                        //$NON-NLS-1$
                        elementValue2.setElementRef("DELIMITER");
                        elementValue2.setValue(delimiterValue);
                        values.add(elementValue2);
                        ElementValueType elementValue3 = fileFact.createElementValueType();
                        //$NON-NLS-1$
                        elementValue3.setElementRef("MERGE");
                        elementValue3.setValue(mergeValue);
                        values.add(elementValue3);
                    }
                    //$NON-NLS-1$ //$NON-NLS-2$
                    ComponentUtilities.addNodeProperty(node, "DENORMALIZE_COLUMNS", "TABLE");
                    //$NON-NLS-1$
                    ComponentUtilities.setNodeProperty(node, "DENORMALIZE_COLUMNS", values);
                    //$NON-NLS-1$
                    ComponentUtilities.removeNodeProperty(node, "DELIMITER");
                    //$NON-NLS-1$
                    ComponentUtilities.removeNodeProperty(node, "MERGE");
                    //$NON-NLS-1$
                    ComponentUtilities.removeNodeProperty(node, "GROUPS");
                }
            }
        };
        ModifyComponentsAction.searchAndModify(item, processType, filter1, Arrays.<IComponentConversion>asList(conversion));
        return ExecutionResult.SUCCESS_NO_ALERT;
    } catch (Exception e) {
        ExceptionHandler.process(e);
        return ExecutionResult.FAILURE;
    }
}
Also used : ColumnType(org.talend.designer.core.model.utils.emf.talendfile.ColumnType) IComponentFilter(org.talend.core.model.components.filters.IComponentFilter) ArrayList(java.util.ArrayList) MetadataType(org.talend.designer.core.model.utils.emf.talendfile.MetadataType) NameComponentFilter(org.talend.core.model.components.filters.NameComponentFilter) 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) TalendFileFactory(org.talend.designer.core.model.utils.emf.talendfile.TalendFileFactory) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) IComponentConversion(org.talend.core.model.components.conversions.IComponentConversion)

Example 25 with ElementValueType

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

the class SubstituteRemovedMDMOperatorMigrationTask 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[] { "tMDMInput", "tMDMDelete", "tMDMViewSearch" };
    IComponentConversion substituteRemovedOperatorsFromJobItem = new IComponentConversion() {

        public void transform(NodeType node) {
            ElementParameterType operations = ComponentUtilities.getNodeProperty(node, "OPERATIONS");
            if (operations != null && operations.getElementValue().size() > 0) {
                for (ElementValueType elementValue : (List<ElementValueType>) operations.getElementValue()) {
                    if ("STRICTCONTAINS".equals(elementValue.getValue()) && "FUNCTION".equals(elementValue.getElementRef())) {
                        elementValue.setValue("CONTAINS");
                    }
                }
            }
        }
    };
    for (String name : componentsName) {
        //$NON-NLS-1$
        IComponentFilter filter = new NameComponentFilter(name);
        try {
            ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(substituteRemovedOperatorsFromJobItem));
        } 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) 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) List(java.util.List) IComponentConversion(org.talend.core.model.components.conversions.IComponentConversion)

Aggregations

ElementValueType (org.talend.designer.core.model.utils.emf.talendfile.ElementValueType)35 ElementParameterType (org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType)28 NodeType (org.talend.designer.core.model.utils.emf.talendfile.NodeType)21 ProcessType (org.talend.designer.core.model.utils.emf.talendfile.ProcessType)16 IComponentConversion (org.talend.core.model.components.conversions.IComponentConversion)15 IComponentFilter (org.talend.core.model.components.filters.IComponentFilter)15 NameComponentFilter (org.talend.core.model.components.filters.NameComponentFilter)13 ArrayList (java.util.ArrayList)12 List (java.util.List)11 EList (org.eclipse.emf.common.util.EList)8 HashMap (java.util.HashMap)7 Map (java.util.Map)6 PersistenceException (org.talend.commons.exception.PersistenceException)6 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)5 ProxyRepositoryFactory (org.talend.core.repository.model.ProxyRepositoryFactory)4 ConnectionType (org.talend.designer.core.model.utils.emf.talendfile.ConnectionType)4 HashSet (java.util.HashSet)2 EObject (org.eclipse.emf.ecore.EObject)2 ECodeLanguage (org.talend.core.language.ECodeLanguage)2 RemovePropertyComponentConversion (org.talend.core.model.components.conversions.RemovePropertyComponentConversion)2