use of org.talend.designer.core.model.utils.emf.talendfile.ElementValueType in project tdi-studio-se by Talend.
the class ChangeELTHiveOutputPartitionValue method wrapQuot.
private boolean wrapQuot(Item item, ProcessType processType) throws PersistenceException {
ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
boolean modified = false;
EList node = processType.getNode();
for (Object n : node) {
NodeType type = (NodeType) n;
if (type.getComponentName().equals("tELTHiveOutput")) {
//$NON-NLS-1$
EList elementParameterList = type.getElementParameter();
for (Object elem : elementParameterList) {
ElementParameterType elemType = (ElementParameterType) elem;
if (elemType.getName().equals("FIELD_PARTITION")) {
//$NON-NLS-1$
EList elemValue = elemType.getElementValue();
for (Object eVal : elemValue) {
ElementValueType elemVal = (ElementValueType) eVal;
String originV = elemVal.getValue();
//$NON-NLS-1$ //$NON-NLS-2$
elemVal.setValue("\"" + originV + "\"");
modified = true;
}
}
}
}
}
if (modified) {
factory.save(item, true);
}
return modified;
}
use of org.talend.designer.core.model.utils.emf.talendfile.ElementValueType 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.ElementValueType in project tdi-studio-se by Talend.
the class SetDefaultValue4tWriteJSONFieldGroupByOutput method execute.
@Override
public ExecutionResult execute(Item item) {
ProcessType processType = getProcessType(item);
IComponentFilter filter = new NameComponentFilter("tWriteJSONField");
try {
ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(new IComponentConversion() {
public void transform(NodeType node) {
EList<ElementValueType> list = ComponentUtilities.getNodeProperty(node, "GROUPBYS").getElementValue();
ElementValueType outputColumnPropertyElement = null;
int size = list.size();
if (list != null && size > 0) {
String outputFieldValue = ComponentUtilities.getNodeProperty(node, "JSONFIELD").getValue();
for (int i = 0, j = 0; i < size; i++) {
outputColumnPropertyElement = TalendFileFactory.eINSTANCE.createElementValueType();
//$NON-NLS-1$
outputColumnPropertyElement.setElementRef("OUTPUT_COLUMN");
outputColumnPropertyElement.setValue(outputFieldValue);
list.add(j, outputColumnPropertyElement);
j = j + 2;
}
}
}
}));
} catch (PersistenceException e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
return ExecutionResult.SUCCESS_NO_ALERT;
}
use of org.talend.designer.core.model.utils.emf.talendfile.ElementValueType 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.ElementValueType in project tdi-studio-se by Talend.
the class ChangeRecordMatchingCustomFunctionValueTask 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 processType = getProcessType(item);
if (processType == null) {
return ExecutionResult.NOTHING_TO_DO;
}
IComponentConversion changeCustomFunctionValue = new IComponentConversion() {
@Override
public void transform(NodeType node) {
//$NON-NLS-1$
ElementParameterType eleParam = ComponentUtilities.getNodeProperty(node, "JOIN_KEY");
if (eleParam != null) {
EList<ElementValueType> currentEleValues = eleParam.getElementValue();
Iterator<ElementValueType> iterator = currentEleValues.iterator();
while (iterator.hasNext()) {
ElementValueType param = iterator.next();
if ("MATCHING_TYPE".equals(param.getElementRef()) && "Custom".equals(param.getValue())) {
//$NON-NLS-1$ //$NON-NLS-2$
//$NON-NLS-1$
param.setValue("custom");
}
}
}
}
};
try {
List<IComponentFilter> filters = new ArrayList<IComponentFilter>();
//$NON-NLS-1$
filters.add(new NameComponentFilter("tRecordMatching"));
Iterator<IComponentFilter> iter = filters.iterator();
while (iter.hasNext()) {
IComponentFilter filter = iter.next();
ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(changeCustomFunctionValue));
}
return ExecutionResult.SUCCESS_NO_ALERT;
} catch (Exception e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
Aggregations