Search in sources :

Example 16 with ElementParameterType

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;
}
Also used : ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType)

Example 17 with ElementParameterType

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);
}
Also used : ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) ElementValueType(org.talend.designer.core.model.utils.emf.talendfile.ElementValueType) List(java.util.List) ArrayList(java.util.ArrayList)

Example 18 with ElementParameterType

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;
}
Also used : ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) EList(org.eclipse.emf.common.util.EList) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) ArrayList(java.util.ArrayList)

Example 19 with ElementParameterType

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;
}
Also used : ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) ElementValueType(org.talend.designer.core.model.utils.emf.talendfile.ElementValueType) List(java.util.List)

Example 20 with ElementParameterType

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;
        }
    }
}
Also used : ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) EList(org.eclipse.emf.common.util.EList) ElementValueType(org.talend.designer.core.model.utils.emf.talendfile.ElementValueType)

Aggregations

ElementParameterType (org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType)197 NodeType (org.talend.designer.core.model.utils.emf.talendfile.NodeType)126 ProcessType (org.talend.designer.core.model.utils.emf.talendfile.ProcessType)114 PersistenceException (org.talend.commons.exception.PersistenceException)86 IComponentConversion (org.talend.core.model.components.conversions.IComponentConversion)85 IComponentFilter (org.talend.core.model.components.filters.IComponentFilter)83 NameComponentFilter (org.talend.core.model.components.filters.NameComponentFilter)83 EList (org.eclipse.emf.common.util.EList)40 ElementValueType (org.talend.designer.core.model.utils.emf.talendfile.ElementValueType)28 ProxyRepositoryFactory (org.talend.core.repository.model.ProxyRepositoryFactory)25 List (java.util.List)22 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)19 ArrayList (java.util.ArrayList)16 ProcessItem (org.talend.core.model.properties.ProcessItem)16 ParametersType (org.talend.designer.core.model.utils.emf.talendfile.ParametersType)15 ConnectionType (org.talend.designer.core.model.utils.emf.talendfile.ConnectionType)13 JobletProcessItem (org.talend.core.model.properties.JobletProcessItem)9 HashMap (java.util.HashMap)7 IOException (java.io.IOException)6 IElementParameter (org.talend.core.model.process.IElementParameter)6