Search in sources :

Example 81 with ElementParameterType

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

the class SettingValuesIntoHadoopPropertiesFortHiveConnection method execute.

public ExecutionResult execute(Item item) {
    final ProcessType processType = getProcessType(item);
    try {
        //$NON-NLS-1$
        IComponentFilter filter = new NameComponentFilter("tELTHiveMap");
        ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(new IComponentConversion() {

            public void transform(NodeType node) {
                //$NON-NLS-1$ //$NON-NLS-2$
                ElementParameterType useExistingConn = ComponentUtilities.getNodeProperty(node, "USE_EXISTING_CONNECTION");
                if (useExistingConn != null && "true".equalsIgnoreCase(useExistingConn.getValue())) {
                    //$NON-NLS-1$
                    ElementParameterType connNamePara = ComponentUtilities.getNodeProperty(node, "CONNECTION");
                    if (connNamePara != null) {
                        NodeType tHiveConnNode = searchNodeTypeByUniqName(processType, connNamePara.getValue());
                        moveValuesFromHiveMap2HiveConn(node, tHiveConnNode);
                    }
                }
            }
        }));
        return ExecutionResult.SUCCESS_NO_ALERT;
    } catch (PersistenceException e) {
        // TODO Auto-generated catch block
        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) PersistenceException(org.talend.commons.exception.PersistenceException) NameComponentFilter(org.talend.core.model.components.filters.NameComponentFilter) IComponentConversion(org.talend.core.model.components.conversions.IComponentConversion)

Example 82 with ElementParameterType

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

the class SettingValuesIntoHadoopPropertiesFortHiveConnection method moveValuesFromHiveMap2HiveConn.

/* <p>
	 * Copy the values of these parameters:SET_MAPRED_JT, MAPRED_JT, SET_FS_DEFAULT_NAME, FS_DEFAULT_NAME and HADOOP_ADVANCED_PROPERTIES
	 * From the tELTHiveMap to the tHiveConnection when the "Use Existing Connection" in tELTHiveMap is ticked.
	 * </p>
	 */
private void moveValuesFromHiveMap2HiveConn(NodeType tHiveMapNode, NodeType tHiveConnNode) {
    if (tHiveMapNode == null || tHiveConnNode == null) {
        return;
    }
    //$NON-NLS-1$
    ElementParameterType setMapredJt = ComponentUtilities.getNodeProperty(tHiveMapNode, "SET_MAPRED_JT");
    //$NON-NLS-1$	
    ElementParameterType mapredJt = ComponentUtilities.getNodeProperty(tHiveMapNode, "MAPRED_JT");
    if ((setMapredJt != null && "true".equalsIgnoreCase(setMapredJt.getValue())) && mapredJt != null) {
        //$NON-NLS-1$
        ElementParameterType setMapredJt2 = ComponentUtilities.getNodeProperty(tHiveConnNode, "SET_MAPRED_JT");
        //$NON-NLS-1$
        ElementParameterType mapredJt2 = ComponentUtilities.getNodeProperty(tHiveConnNode, "MAPRED_JT");
        if (setMapredJt2 == null) {
            ComponentUtilities.addNodeProperty(tHiveConnNode, "SET_MAPRED_JT", "CHECK");
        }
        ComponentUtilities.setNodeValue(tHiveConnNode, "SET_MAPRED_JT", "true");
        if (mapredJt2 == null) {
            ComponentUtilities.addNodeProperty(tHiveConnNode, "MAPRED_JT", "TEXT");
        }
        ComponentUtilities.setNodeValue(tHiveConnNode, "MAPRED_JT", mapredJt.getValue());
    }
    //$NON-NLS-1$
    ElementParameterType setFsDefaultName = ComponentUtilities.getNodeProperty(tHiveMapNode, "SET_FS_DEFAULT_NAME");
    //$NON-NLS-1$
    ElementParameterType fsDefaultName = ComponentUtilities.getNodeProperty(tHiveMapNode, "FS_DEFAULT_NAME");
    if ((setFsDefaultName != null && "true".equalsIgnoreCase(setFsDefaultName.getValue())) && fsDefaultName != null) {
        //$NON-NLS-1$
        ElementParameterType setFsDefaultName2 = ComponentUtilities.getNodeProperty(tHiveConnNode, "SET_FS_DEFAULT_NAME");
        //$NON-NLS-1$
        ElementParameterType fsDefaultName2 = ComponentUtilities.getNodeProperty(tHiveConnNode, "FS_DEFAULT_NAME");
        if (setFsDefaultName2 == null) {
            ComponentUtilities.addNodeProperty(tHiveConnNode, "SET_FS_DEFAULT_NAME", "CHECK");
        }
        ComponentUtilities.setNodeValue(tHiveConnNode, "SET_FS_DEFAULT_NAME", "true");
        if (fsDefaultName2 == null) {
            ComponentUtilities.addNodeProperty(tHiveConnNode, "FS_DEFAULT_NAME", "TEXT");
        }
        ComponentUtilities.setNodeValue(tHiveConnNode, "FS_DEFAULT_NAME", fsDefaultName.getValue());
    }
    ElementParameterType hadoopAdvancedPropertiesParam = //$NON-NLS-1$
    ComponentUtilities.getNodeProperty(tHiveMapNode, "HADOOP_ADVANCED_PROPERTIES");
    if (hadoopAdvancedPropertiesParam != null) {
        //$NON-NLS-1$
        EList<ElementValueType> hadoopAdvancedProperties = hadoopAdvancedPropertiesParam.getElementValue();
        ElementValueType columnNamePropertyElement = null;
        ElementValueType columnNameValueElement = null;
        if (hadoopAdvancedProperties != null && hadoopAdvancedProperties.size() > 0) {
            ElementParameterType hadoopAdvancedPropertiesParam2 = //$NON-NLS-1$
            ComponentUtilities.getNodeProperty(tHiveConnNode, "HADOOP_ADVANCED_PROPERTIES");
            if (hadoopAdvancedPropertiesParam2 == null) {
                ComponentUtilities.addNodeProperty(tHiveConnNode, "HADOOP_ADVANCED_PROPERTIES", "TABLE");
                hadoopAdvancedPropertiesParam2 = ComponentUtilities.getNodeProperty(tHiveConnNode, "HADOOP_ADVANCED_PROPERTIES");
            }
            for (int i = 0; i < hadoopAdvancedProperties.size(); i = i + 2) {
                columnNamePropertyElement = TalendFileFactory.eINSTANCE.createElementValueType();
                //$NON-NLS-1$
                columnNamePropertyElement.setElementRef("PROPERTY");
                columnNamePropertyElement.setValue(hadoopAdvancedProperties.get(i).getValue());
                hadoopAdvancedPropertiesParam2.getElementValue().add(columnNamePropertyElement);
                columnNameValueElement = TalendFileFactory.eINSTANCE.createElementValueType();
                //$NON-NLS-1$
                columnNameValueElement.setElementRef("VALUE");
                columnNameValueElement.setValue(hadoopAdvancedProperties.get(i + 1).getValue());
                hadoopAdvancedPropertiesParam2.getElementValue().add(columnNameValueElement);
            }
        }
    }
}
Also used : ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) ElementValueType(org.talend.designer.core.model.utils.emf.talendfile.ElementValueType)

Example 83 with ElementParameterType

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

the class SetDefaultVauleMDMServerVersionFeatureTDI31722 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", "tMDMOutput", "tMDMDelete", "tMDMConnection", "tMDMViewSearch", "tMDMSP" };
    IComponentConversion changeDeletEmptyFileValue = new IComponentConversion() {

        public void transform(NodeType node) {
            ElementParameterType serverVersion = ComponentUtilities.getNodeProperty(node, "SERVERVERSION");
            if (serverVersion == null) {
                ComponentUtilities.addNodeProperty(node, "SERVERVERSION", "CLOSED_LIST");
                serverVersion = ComponentUtilities.getNodeProperty(node, "SERVERVERSION");
                serverVersion.setValue("s56");
            }
        }
    };
    for (String name : componentsName) {
        //$NON-NLS-1$
        IComponentFilter filter = new NameComponentFilter(name);
        try {
            ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(changeDeletEmptyFileValue));
        } 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)

Example 84 with ElementParameterType

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

the class SetFilterTiemFromTotoFromPOPComponentsMigrationTask 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 (processType == null) {
        return ExecutionResult.NOTHING_TO_DO;
    }
    try {
        IComponentFilter filter = new NameComponentFilter("tPOP");
        ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(new IComponentConversion() {

            public void transform(NodeType node) {
                ElementParameterType p = ComponentUtilities.getNodeProperty(node, "ADVANCED_FILTER");
                EList<ElementValueType> es = p.getElementValue();
                for (int j = 0; j < es.size(); j++) {
                    if (es.get(j) != null && "To".equals(es.get(j).getValue())) {
                        es.get(j).setValue("From");
                    }
                }
            }
        }));
        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) ElementValueType(org.talend.designer.core.model.utils.emf.talendfile.ElementValueType) 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 85 with ElementParameterType

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

the class RenametParseXMLRowTotExtractXMLFieldMigrationTask method execute.

public ExecutionResult execute(Item item) {
    ProcessType processType = getProcessType(item);
    if (getProject().getLanguage() == ECodeLanguage.JAVA && processType != null) {
        try {
            //$NON-NLS-1$
            IComponentFilter filter1 = new NameComponentFilter("tParseXMLRow");
            IComponentConversion changeNodeNameConversion = new IComponentConversion() {

                public void transform(NodeType node) {
                    ProcessType item = (ProcessType) node.eContainer();
                    for (Object o : item.getNode()) {
                        NodeType nt = (NodeType) o;
                        for (Object o1 : nt.getElementParameter()) {
                            ElementParameterType t = (ElementParameterType) o1;
                            String value = t.getValue();
                            if (value != null) {
                                if (value.contains("tParseXMLRow")) {
                                    //$NON-NLS-1$
                                    //$NON-NLS-1$ //$NON-NLS-2$
                                    String replaceAll = value.replaceAll("tParseXMLRow", "tExtractXMLField");
                                    t.setValue(replaceAll);
                                }
                            }
                        }
                    }
                }
            };
            // bug 22125
            ModifyComponentsAction.searchAndModify(item, processType, filter1, Arrays.<IComponentConversion>asList(new RenameComponentConversion("tExtractXMLField")));
            return ExecutionResult.SUCCESS_WITH_ALERT;
        } catch (Exception e) {
            ExceptionHandler.process(e);
            return ExecutionResult.FAILURE;
        }
    } else {
        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) 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) RenameComponentConversion(org.talend.core.model.components.conversions.RenameComponentConversion) 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