use of org.talend.designer.core.model.utils.emf.talendfile.ElementValueType in project tdi-studio-se by Talend.
the class MoveExcelSheetnameToSheetlistForJava method execute.
@Override
public ExecutionResult execute(Item item) {
ProcessType processType = getProcessType(item);
if (getProject().getLanguage() == ECodeLanguage.PERL || processType == null) {
return ExecutionResult.NOTHING_TO_DO;
}
try {
//$NON-NLS-1$
IComponentFilter filter1 = new NameComponentFilter("tFileInputExcel");
IComponentConversion addNewProperty = new IComponentConversion() {
public void transform(NodeType node) {
//$NON-NLS-1$ //$NON-NLS-2$
ComponentUtilities.addNodeProperty(node, "SHEETLIST", "TABLE");
List<ElementValueType> values = new ArrayList<ElementValueType>();
ElementValueType eValue = TalendFileFactory.eINSTANCE.createElementValueType();
//$NON-NLS-1$
eValue.setElementRef("SHEETNAME");
//$NON-NLS-1$
eValue.setValue(ComponentUtilities.getNodePropertyValue(node, "SHEETNAME"));
values.add(eValue);
//$NON-NLS-1$
ComponentUtilities.setNodeProperty(node, "SHEETLIST", values);
}
};
//$NON-NLS-1$
IComponentConversion removeOldProperty = new RemovePropertyComponentConversion("SHEETNAME");
ModifyComponentsAction.searchAndModify(item, processType, filter1, Arrays.<IComponentConversion>asList(addNewProperty, removeOldProperty));
return ExecutionResult.SUCCESS_WITH_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 MoveFileListFilemaskToFilemaskListForJava method execute.
@Override
public ExecutionResult execute(Item item) {
ProcessType processType = getProcessType(item);
if (getProject().getLanguage() == ECodeLanguage.PERL || processType == null) {
return ExecutionResult.NOTHING_TO_DO;
}
try {
//$NON-NLS-1$
IComponentFilter filter1 = new NameComponentFilter("tFileList");
IComponentConversion addNewProperty = new IComponentConversion() {
public void transform(NodeType node) {
//$NON-NLS-1$ //$NON-NLS-2$
ComponentUtilities.addNodeProperty(node, "FILES", "TABLE");
List<ElementValueType> values = new ArrayList<ElementValueType>();
ElementValueType eValue = TalendFileFactory.eINSTANCE.createElementValueType();
//$NON-NLS-1$
eValue.setElementRef("FILEMASK");
//$NON-NLS-1$
eValue.setValue(ComponentUtilities.getNodePropertyValue(node, "FILEMASK"));
values.add(eValue);
//$NON-NLS-1$
ComponentUtilities.setNodeProperty(node, "FILES", values);
}
};
ModifyComponentsAction.searchAndModify(item, processType, filter1, Arrays.<IComponentConversion>asList(addNewProperty));
return ExecutionResult.SUCCESS_WITH_ALERT;
} catch (Exception e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
use of org.talend.designer.core.model.utils.emf.talendfile.ElementValueType in project tesb-studio-se by Talend.
the class CSetHeaderSupportMultiHeadersTask method cSetHeaderMigrate.
@SuppressWarnings({ "rawtypes", "unchecked" })
private void cSetHeaderMigrate(NodeType currentNode) throws PersistenceException {
List parameters = currentNode.getElementParameter();
String headerName = null;
String useBean = null;
String expression = null;
String language = null;
String bean = null;
for (Object tmp : parameters) {
ElementParameterType param = (ElementParameterType) tmp;
String paramName = param.getName();
if ("HEADER".equals(paramName)) {
headerName = param.getValue();
} else if ("USE_BEAN".equals(paramName)) {
useBean = param.getValue();
} else if ("BEAN".equals(paramName)) {
bean = param.getValue();
} else if ("LANGUAGES".equals(paramName)) {
language = param.getValue();
} else if ("EXPRESSION".equals(paramName)) {
expression = param.getValue();
}
}
// setName
ElementValueType newNameValue = TalendFileFactory.eINSTANCE.createElementValueType();
newNameValue.setElementRef("NAME");
newNameValue.setValue(headerName);
// set LANGUAGE
ElementValueType newLanguageValue = TalendFileFactory.eINSTANCE.createElementValueType();
newLanguageValue.setElementRef("LANGUAGE");
if ("true".equals(useBean)) {
newLanguageValue.setValue("bean");
} else {
newLanguageValue.setValue(language);
}
// set EXPRESSION
ElementValueType newExpressionValue = TalendFileFactory.eINSTANCE.createElementValueType();
newExpressionValue.setElementRef("EXPRESSION");
if ("true".equals(useBean)) {
newExpressionValue.setValue(bean);
} else {
newExpressionValue.setValue(expression);
}
ElementParameterType newParameter = TalendFileFactory.eINSTANCE.createElementParameterType();
newParameter.setName("VALUES");
newParameter.setField("TABLE");
newParameter.getElementValue().add(newNameValue);
newParameter.getElementValue().add(newLanguageValue);
newParameter.getElementValue().add(newExpressionValue);
parameters.add(newParameter);
}
use of org.talend.designer.core.model.utils.emf.talendfile.ElementValueType in project tesb-studio-se by Talend.
the class ConsumesTypeMigrationTask method updateConsumesType.
/**
* Update consumes type in case POST/PUT, set default consumes type to
* "XML-JSON".
*
* @param currentNode
* the current node
* @return true, if successful
*/
@SuppressWarnings("unchecked")
private boolean updateConsumesType(NodeType currentNode) {
List<?> elementParameter = currentNode.getElementParameter();
ElementParameterType schemasParam = findElementByName(elementParameter, "SCHEMAS", ElementParameterType.class);
if (schemasParam == null) {
return false;
}
@SuppressWarnings("rawtypes") List elementValues = schemasParam.getElementValue();
ElementValueType value_HTTP_VERB = findElementByName(elementValues, "HTTP_VERB", ElementValueType.class);
ElementValueType value_CONSUMES = findElementByName(elementValues, "CONSUMES", ElementValueType.class);
if (value_HTTP_VERB == null || value_CONSUMES != null) {
return false;
}
if (value_HTTP_VERB.getValue().equals("POST") || value_HTTP_VERB.getValue().equals("PUT")) {
value_CONSUMES = TalendFileFactory.eINSTANCE.createElementValueType();
value_CONSUMES.setElementRef("CONSUMES");
value_CONSUMES.setValue("XML-JSON");
elementValues.add(value_CONSUMES);
return true;
}
return false;
}
use of org.talend.designer.core.model.utils.emf.talendfile.ElementValueType in project tesb-studio-se by Talend.
the class FormContentTypeMigrationTask method updateFormConsumeContentTypeFor.
private void updateFormConsumeContentTypeFor(String connectorName, NodeType currentNode) {
for (Object o : currentNode.getElementParameter()) {
if (!(o instanceof ElementParameterType)) {
continue;
}
ElementParameterType ept = (ElementParameterType) o;
if ("SCHEMAS".equals(ept.getName())) {
EList elementValue = ept.getElementValue();
if (elementValue == null || elementValue.isEmpty()) {
break;
}
int size = elementValue.size();
for (int i = 0; i < size; i++) {
ElementValueType evt = (ElementValueType) elementValue.get(i);
if ("SCHEMA".equals(evt.getElementRef()) && connectorName.equals(evt.getValue())) {
/*
* i+1 : HTTP_VERB i+2 : URI_PATTERN
*/
if (i + 3 == size) {
ElementValueType newType = TalendFileFactory.eINSTANCE.createElementValueType();
newType.setElementRef("CONSUMES");
newType.setValue("FORM");
elementValue.add(newType);
} else if (i + 3 < size && !"CONSUMES".equals((ElementValueType) elementValue.get(i + 3))) {
ElementValueType newType = TalendFileFactory.eINSTANCE.createElementValueType();
newType.setElementRef("CONSUMES");
newType.setValue("FORM");
elementValue.add(i + 3, newType);
}
break;
}
}
break;
}
}
}
Aggregations