use of org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType in project tesb-studio-se by Talend.
the class CLogLoggingCategoryMigrationTask method execute.
@Override
protected boolean execute(NodeType node) throws Exception {
@SuppressWarnings("unchecked") List<ElementParameterType> parameters = node.getElementParameter();
boolean hasLoggingCategory = false;
String label = null;
String cid = null;
for (ElementParameterType param : parameters) {
if (LOGGING_CATEGORY.equals(param.getName())) {
hasLoggingCategory = true;
} else if ("LABEL".equals(param.getName())) {
label = param.getValue();
} else if ("UNIQUE_NAME".equals(param.getName())) {
cid = param.getValue();
}
}
if (hasLoggingCategory) {
return false;
}
if (label != null && !"__UNIQUE_NAME__".equals(label)) {
cid = label + "_" + cid;
}
ElementParameterType newParameter = TalendFileFactory.eINSTANCE.createElementParameterType();
newParameter.setName(LOGGING_CATEGORY);
newParameter.setValue("\"" + cid + "\"");
parameters.add(newParameter);
return true;
}
use of org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType 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.ElementParameterType in project tesb-studio-se by Talend.
the class DisconnectErroHandlerMigrationTask method findAllErrorHandlerIds.
private List<String> findAllErrorHandlerIds(ProcessType pt) {
List<String> errorHandlers = new ArrayList<String>();
for (Object o : pt.getNode()) {
if (!(o instanceof NodeType)) {
continue;
}
NodeType nt = (NodeType) o;
if (!"cErrorHandler".equals(nt.getComponentName())) {
continue;
}
EList elementParameter = nt.getElementParameter();
for (Object e : elementParameter) {
if (!(e instanceof ElementParameterType)) {
continue;
}
ElementParameterType ept = (ElementParameterType) e;
if ("UNIQUE_NAME".equals(ept.getName())) {
errorHandlers.add(ept.getValue());
}
}
}
return errorHandlers;
}
use of org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType 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.ElementParameterType 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