use of org.talend.designer.core.model.utils.emf.talendfile.ElementValueType in project tesb-studio-se by Talend.
the class CamelFeatureUtil method handleSetHeaderCase.
private static void handleSetHeaderCase(Collection<FeatureModel> features, NodeType currentNode) {
ElementParameterType element = EmfModelUtils.findElementParameterByName("VALUES", currentNode);
Iterator<?> iterator = element.getElementValue().iterator();
while (iterator.hasNext()) {
Object next = iterator.next();
if (!(next instanceof ElementValueType)) {
continue;
}
ElementValueType evt = (ElementValueType) next;
String elementRef = evt.getElementRef();
if ("LANGUAGE".equals(elementRef) && JAVA_SCRIPT.equals(evt.getValue())) {
features.add(FEATURE_CAMEL_SCRIPT_JAVASCRIPT);
break;
}
}
}
use of org.talend.designer.core.model.utils.emf.talendfile.ElementValueType in project tesb-studio-se by Talend.
the class ExManifestItem method satisfy.
private boolean satisfy(final NodeType nodeType) {
if (predicates.isEmpty()) {
return true;
}
final Collection<?> parameters = nodeType.getElementParameter();
for (Map.Entry<String, String> predicate : predicates.entrySet()) {
String attributeName = predicate.getKey();
final String attributeValue = predicate.getValue();
final String[] segments = attributeName.split(SEPARATOR);
String valueName = null;
if (segments.length > 1) {
attributeName = segments[0];
valueName = segments[1];
}
for (Object o : parameters) {
final ElementParameterType ept = (ElementParameterType) o;
if (ept.getName().equals(attributeName)) {
if (null == valueName) {
if (!attributeValue.equals(ept.getValue())) {
return false;
}
} else {
boolean found = false;
for (Object e : ept.getElementValue()) {
final ElementValueType evt = (ElementValueType) e;
if (valueName.equals(evt.getElementRef()) && attributeValue.equals(evt.getValue())) {
found = true;
break;
}
}
if (!found) {
return false;
}
}
break;
}
}
}
return true;
}
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;
}
}
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);
}
}
}
}
Aggregations