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;
}
}
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);
}
}
}
}
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;
}
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;
}
}
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;
}
}
Aggregations