Search in sources :

Example 16 with MigrationReportRecorder

use of org.talend.migration.MigrationReportRecorder in project tesb-studio-se by Talend.

the class UpdateMQTTMigrationTask method replaceValuesOfParas.

private boolean replaceValuesOfParas(NodeType currentNode) throws PersistenceException {
    boolean needSave = false;
    ElementParameterType param = UtilTool.findParameterType(currentNode, "MQTT_RECONNECT_DELAY");
    String value = param.getValue();
    for (Object e : currentNode.getElementParameter()) {
        ElementParameterType p = (ElementParameterType) e;
        if ("MQTT_RECONNECT_DELAY".equals(p.getName())) {
            p.setValue(value);
            needSave = true;
            generateReportRecord(new MigrationReportRecorder(this, MigrationReportRecorder.MigrationOperationType.MODIFY, getRouteItem(), currentNode, "MQTT_RECONNECT_DELAY of cMQConnectionFactory", "", value));
            break;
        }
    }
    ElementParameterType paramQOS = UtilTool.findParameterType(currentNode, "MQTT_QOS");
    String valueQOS = paramQOS.getValue();
    for (Object e : currentNode.getElementParameter()) {
        ElementParameterType p = (ElementParameterType) e;
        if ("MQTT_QOS".equals(p.getName())) {
            if ("AtLeastOnce".equalsIgnoreCase(valueQOS)) {
                p.setValue("0");
                needSave = true;
            }
            if ("AtMostOnce".equalsIgnoreCase(valueQOS)) {
                p.setValue("1");
                needSave = true;
            }
            if ("ExactlyOnce".equalsIgnoreCase(valueQOS)) {
                p.setValue("2");
                needSave = true;
            }
        }
    }
    return needSave;
}
Also used : ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) MigrationReportRecorder(org.talend.migration.MigrationReportRecorder)

Example 17 with MigrationReportRecorder

use of org.talend.migration.MigrationReportRecorder in project tesb-studio-se by Talend.

the class AddBeansDefaultLibrariesMigrationTask method addModulesNeededForBeans.

private void addModulesNeededForBeans(BeanItem beanItem) {
    List<ModuleNeeded> importNeedsList = ModulesNeededProvider.getModulesNeededForBeans();
    for (ModuleNeeded model : importNeedsList) {
        IMPORTType importType = ComponentFactory.eINSTANCE.createIMPORTType();
        importType.setMODULE(model.getModuleName());
        importType.setMESSAGE(model.getInformationMsg());
        importType.setREQUIRED(model.isRequired());
        importType.setMVN(model.getMavenUri());
        if (!beanItem.getImports().contains(importType)) {
            String message = String.format("Adding module needed for beans: %s", importType.getMODULE());
            generateReportRecord(new MigrationReportRecorder(this, MigrationReportRecorder.MigrationOperationType.ADD, beanItem, null, message, null, null));
            beanItem.getImports().add(importType);
        } else {
            String message = String.format("Duplicate module found: %s", importType.getMODULE());
            generateReportRecord(new MigrationReportRecorder(this, MigrationReportRecorder.MigrationOperationType.ADD, beanItem, null, message, null, null));
        }
    }
}
Also used : IMPORTType(org.talend.designer.core.model.utils.emf.component.IMPORTType) MigrationReportRecorder(org.talend.migration.MigrationReportRecorder) ModuleNeeded(org.talend.core.model.general.ModuleNeeded)

Example 18 with MigrationReportRecorder

use of org.talend.migration.MigrationReportRecorder in project tesb-studio-se by Talend.

the class DeprecatedBodyExpressionsMigrationTask method updateBodyExpressions.

@SuppressWarnings("unchecked")
private boolean updateBodyExpressions(NodeType currentNode) throws PersistenceException {
    save = false;
    if ("cSetHeader".equalsIgnoreCase(currentNode.getComponentName())) {
        ElementParameterType paramValues = UtilTool.findParameterType(currentNode, "VALUES");
        paramValues.getElementValue().forEach(e -> {
            ElementValueType element = (ElementValueType) e;
            String name = ((ElementValueType) element).getElementRef();
            String value = ((ElementValueType) element).getValue();
            if ("NONE".equalsIgnoreCase(name)) {
                valueLanguage = value;
            }
            if ("EXPRESSION".equalsIgnoreCase(name) && "NONE".equalsIgnoreCase(valueLanguage)) {
                valueExpression = value;
                String correctedBodyExpressions = correctBodyExpressions(valueExpression);
                if (!valueExpression.equalsIgnoreCase(correctedBodyExpressions)) {
                    element.setValue(correctedBodyExpressions);
                    save = true;
                    generateReportRecord(new MigrationReportRecorder(this, MigrationReportRecorder.MigrationOperationType.MODIFY, getRouteItem(), currentNode, "Language Expression", valueExpression, correctedBodyExpressions));
                }
            }
        });
    } else {
        ElementParameterType paramLanguages = UtilTool.findParameterType(currentNode, "LANGUAGES");
        ElementParameterType paramExpression = UtilTool.findParameterType(currentNode, "EXPRESSION");
        if (paramLanguages == null || paramExpression == null) {
            return false;
        }
        valueLanguage = paramLanguages.getValue();
        valueExpression = paramExpression.getValue();
        if (valueLanguage == null || valueExpression == null) {
            return false;
        }
        if (valueLanguage.equalsIgnoreCase("NONE")) {
            String correctedBodyExpressions = correctBodyExpressions(valueExpression);
            if (!valueExpression.equalsIgnoreCase(correctedBodyExpressions)) {
                valueExpression = correctedBodyExpressions;
                save = true;
                generateReportRecord(new MigrationReportRecorder(this, MigrationReportRecorder.MigrationOperationType.MODIFY, getRouteItem(), currentNode, "Language Expression", valueExpression, correctedBodyExpressions));
            }
            if (save) {
                for (Object e : currentNode.getElementParameter()) {
                    ElementParameterType p = (ElementParameterType) e;
                    if ("EXPRESSION".equals(p.getName())) {
                        p.setValue(valueExpression);
                        break;
                    }
                }
            }
        }
    }
    return save;
}
Also used : ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) ElementValueType(org.talend.designer.core.model.utils.emf.talendfile.ElementValueType) MigrationReportRecorder(org.talend.migration.MigrationReportRecorder)

Example 19 with MigrationReportRecorder

use of org.talend.migration.MigrationReportRecorder in project tesb-studio-se by Talend.

the class DeprecatedSimpleLanguageSyntaxMigrationTask method wrapSpecialCommands.

@SuppressWarnings("unchecked")
private boolean wrapSpecialCommands(NodeType currentNode) throws PersistenceException {
    save = false;
    if ("cSetHeader".equalsIgnoreCase(currentNode.getComponentName())) {
        ElementParameterType paramValues = UtilTool.findParameterType(currentNode, "VALUES");
        paramValues.getElementValue().forEach(e -> {
            ElementValueType element = (ElementValueType) e;
            String name = ((ElementValueType) element).getElementRef();
            String value = ((ElementValueType) element).getValue();
            if ("LANGUAGE".equalsIgnoreCase(name)) {
                valueLanguage = value;
            }
            if ("EXPRESSION".equalsIgnoreCase(name) && "SIMPLE".equalsIgnoreCase(valueLanguage)) {
                valueExpression = value;
                String newExpression = wrapBodyAndHeaderExpressions(valueExpression);
                newExpression = replaceKeywords(newExpression);
                if (!valueExpression.equalsIgnoreCase(newExpression)) {
                    element.setValue(newExpression);
                    save = true;
                    generateReportRecord(new MigrationReportRecorder(this, MigrationReportRecorder.MigrationOperationType.MODIFY, getRouteItem(), currentNode, "Language Expression", valueExpression, newExpression));
                }
            }
        });
    } else {
        ElementParameterType paramLanguages = UtilTool.findParameterType(currentNode, "LANGUAGES");
        ElementParameterType paramExpression = UtilTool.findParameterType(currentNode, "EXPRESSION");
        if (paramLanguages == null || paramExpression == null) {
            return false;
        }
        valueLanguage = paramLanguages.getValue();
        valueExpression = paramExpression.getValue();
        if (valueLanguage == null || valueExpression == null) {
            return false;
        }
        valueExpression = valueExpression.replaceAll("\"", "");
        if (valueLanguage.equalsIgnoreCase("SIMPLE")) {
            isOldFormatExpression = isOldFormatExpression(valueExpression, false);
            if (isOldFormatExpression) {
                save = true;
            }
            String newExpression = wrapBodyAndHeaderExpressions(valueExpression);
            newExpression = replaceKeywords(newExpression);
            if (!valueExpression.equalsIgnoreCase(newExpression)) {
                save = true;
            }
            if (save) {
                for (Object e : currentNode.getElementParameter()) {
                    ElementParameterType p = (ElementParameterType) e;
                    if ("EXPRESSION".equals(p.getName())) {
                        String newValueExpression = "";
                        if (isOldFormatExpression) {
                            newValueExpression = "\"" + WRAPPER_START + newExpression + WRAPPER_END + "\"";
                        } else {
                            newValueExpression = "\"" + newExpression + "\"";
                        }
                        p.setValue(newValueExpression);
                        generateReportRecord(new MigrationReportRecorder(this, MigrationReportRecorder.MigrationOperationType.MODIFY, getRouteItem(), currentNode, "Language Expression", valueExpression, newValueExpression));
                        break;
                    }
                }
            }
        }
    }
    return save;
}
Also used : ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) ElementValueType(org.talend.designer.core.model.utils.emf.talendfile.ElementValueType) MigrationReportRecorder(org.talend.migration.MigrationReportRecorder)

Aggregations

MigrationReportRecorder (org.talend.migration.MigrationReportRecorder)19 ElementParameterType (org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType)11 IMPORTType (org.talend.designer.core.model.utils.emf.component.IMPORTType)6 EList (org.eclipse.emf.common.util.EList)5 ElementValueType (org.talend.designer.core.model.utils.emf.talendfile.ElementValueType)5 PersistenceException (org.talend.commons.exception.PersistenceException)4 ModuleNeeded (org.talend.core.model.general.ModuleNeeded)4 ArrayList (java.util.ArrayList)2 IComponentFilter (org.talend.core.model.components.filters.IComponentFilter)2 NameComponentFilter (org.talend.core.model.components.filters.NameComponentFilter)2 NodeType (org.talend.designer.core.model.utils.emf.talendfile.NodeType)2 ProcessType (org.talend.designer.core.model.utils.emf.talendfile.ProcessType)2 Comparator (java.util.Comparator)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Set (java.util.Set)1 BasicEList (org.eclipse.emf.common.util.BasicEList)1