Search in sources :

Example 11 with MigrationReportRecorder

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

the class RenameCamel2ToCamel3PackagesMigrationTask method correctClassNames.

@SuppressWarnings("unchecked")
private boolean correctClassNames(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)) {
                language = value;
            }
            if ("EXPRESSION".equalsIgnoreCase(name)) {
                expression = value;
                String modifiedExpression = renamePackageNamesInsideExpressions(expression);
                if (!expression.equalsIgnoreCase(modifiedExpression)) {
                    ((ElementValueType) element).setValue(modifiedExpression);
                    save = true;
                    generateReportRecord(new MigrationReportRecorder(this, MigrationReportRecorder.MigrationOperationType.MODIFY, getRouteItem(), currentNode, "Language Expression", expression, modifiedExpression));
                }
            }
        });
    } else {
        ElementParameterType paramLanguages = UtilTool.findParameterType(currentNode, "LANGUAGES");
        ElementParameterType paramExpression = UtilTool.findParameterType(currentNode, "EXPRESSION");
        if (paramLanguages == null || paramExpression == null) {
            return false;
        }
        language = paramLanguages.getValue();
        expression = paramExpression.getValue();
        if (language == null || expression == null) {
            return false;
        }
        String modifiedExpression = renamePackageNamesInsideExpressions(expression);
        if (!expression.equalsIgnoreCase(modifiedExpression)) {
            expression = modifiedExpression;
            save = true;
        }
        if (save) {
            for (Object e : currentNode.getElementParameter()) {
                ElementParameterType p = (ElementParameterType) e;
                if ("EXPRESSION".equals(p.getName())) {
                    p.setValue(modifiedExpression);
                    generateReportRecord(new MigrationReportRecorder(this, MigrationReportRecorder.MigrationOperationType.MODIFY, getRouteItem(), currentNode, "Language Expression", expression, modifiedExpression));
                    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 12 with MigrationReportRecorder

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

the class UpdateAWSConnectionRemovedRegionMigrationTask method removeAWSConnectionDefaultRegion.

private boolean removeAWSConnectionDefaultRegion(NodeType nodeType) {
    boolean needSave = false;
    EList<ElementParameterType> list = nodeType.getElementParameter();
    for (ElementParameterType elParameter : list) {
        if ("REGION".equals(elParameter.getName()) && ("\"cn-north-1\"".equals(elParameter.getValue()) || "\"us-gov-west-1\"".equals(elParameter.getValue()))) {
            String value = elParameter.getValue();
            elParameter.setValue("\"us-east-1\"");
            needSave = true;
            String message = "Migrating " + value + " region of cAWSConnection to US East (N. Virginia)";
            generateReportRecord(new MigrationReportRecorder(this, MigrationReportRecorder.MigrationOperationType.MODIFY, getRouteItem(), nodeType, message, "", "us-east-1"));
        }
    }
    return needSave;
}
Also used : ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) MigrationReportRecorder(org.talend.migration.MigrationReportRecorder)

Example 13 with MigrationReportRecorder

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

the class ReplaceDefaultProxyIPMigrationTask method execute.

@Override
public ExecutionResult execute(Item item) {
    IProjectMigrationTask task = this;
    ProcessType processType = getProcessType(item);
    if (getProject().getLanguage() != ECodeLanguage.JAVA || processType == null) {
        return ExecutionResult.NOTHING_TO_DO;
    }
    // $NON-NLS-1$
    String[] componentsName = new String[] { "tESBConsumer", "tRESTClient" };
    for (String name : componentsName) {
        IComponentFilter filter = new NameComponentFilter(name);
        try {
            boolean modified = ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(new IComponentConversion() {

                public void transform(NodeType node) {
                    ElementParameterType useProxy = ComponentUtilities.getNodeProperty(node, "USE_PROXY");
                    if (useProxy == null) {
                        // $NON-NLS-1$
                        return;
                    }
                    ElementParameterType proxyHost = // $NON-NLS-1$
                    ComponentUtilities.getNodeProperty(node, "PROXY_HOST");
                    if (useProxy.getValue().equals("false") && "\"61.163.92.4\"".equals(proxyHost.getValue())) {
                        // $NON-NLS-1$
                        // $NON-NLS-1$
                        proxyHost.setValue("\"127.0.0.1\"");
                        generateReportRecord(new MigrationReportRecorder(task, MigrationReportRecorder.MigrationOperationType.MODIFY, item, node, "PROXY_HOST", "\"61.163.92.4\"", "\"127.0.0.1\""));
                    }
                }
            }));
            if (modified) {
                return ExecutionResult.SUCCESS_WITH_ALERT;
            }
        } catch (PersistenceException e) {
            ExceptionHandler.process(e);
            return ExecutionResult.FAILURE;
        }
    }
    return ExecutionResult.NOTHING_TO_DO;
}
Also used : ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) IComponentFilter(org.talend.core.model.components.filters.IComponentFilter) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) PersistenceException(org.talend.commons.exception.PersistenceException) NameComponentFilter(org.talend.core.model.components.filters.NameComponentFilter) MigrationReportRecorder(org.talend.migration.MigrationReportRecorder) IProjectMigrationTask(org.talend.migration.IProjectMigrationTask) IComponentConversion(org.talend.core.model.components.conversions.IComponentConversion)

Example 14 with MigrationReportRecorder

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

the class UpdateBeansLibrariesMigrationTask method upgradeModulesNeededForBeans.

private void upgradeModulesNeededForBeans(BeanItem beanItem) {
    EList imports = beanItem.getImports();
    for (Object imp : imports) {
        if (imp instanceof IMPORTType) {
            IMPORTType importType = (IMPORTType) imp;
            String fullName = importType.getMODULE();
            String version = fullName.substring(fullName.lastIndexOf('-') + 1, fullName.lastIndexOf("."));
            if (version != null && !version.equals(camelVersion)) {
                if (StringUtils.startsWith(fullName, camelPrefix)) {
                    importType.setMODULE(fullName.replaceAll(version, camelVersion));
                    importType.setMVN(importType.getMVN().replaceAll(version, camelVersion));
                    String message = String.format("Upgrading camel bean dependency version from %s to %s", version, camelPrefix);
                    generateReportRecord(new MigrationReportRecorder(this, MigrationReportRecorder.MigrationOperationType.MODIFY, beanItem, null, message, null, null));
                }
            }
        }
    }
}
Also used : EList(org.eclipse.emf.common.util.EList) IMPORTType(org.talend.designer.core.model.utils.emf.component.IMPORTType) MigrationReportRecorder(org.talend.migration.MigrationReportRecorder)

Example 15 with MigrationReportRecorder

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

the class UpdateJavaDSLProcessorMigrationTask method disableHandleFaultExpression.

private boolean disableHandleFaultExpression(NodeType currentNode) throws PersistenceException {
    boolean needSave = false;
    ElementParameterType param = UtilTool.findParameterType(currentNode, "CODE");
    String originalValue = param.getValue();
    String modifiedValue = "";
    if (originalValue != null) {
        modifiedValue = originalValue.replaceAll("^(?!\\/\\*)\\.handleFault\\(\\)(?!\\*/)*", "/\\*\\.handleFault\\(\\)\\*/");
        if (originalValue.equals(modifiedValue)) {
            return false;
        }
    }
    for (Object e : currentNode.getElementParameter()) {
        ElementParameterType p = (ElementParameterType) e;
        if ("CODE".equals(p.getName())) {
            p.setValue(modifiedValue);
            needSave = true;
            generateReportRecord(new MigrationReportRecorder(this, MigrationReportRecorder.MigrationOperationType.MODIFY, getRouteItem(), currentNode, "CODE", originalValue, modifiedValue));
            break;
        }
    }
    return needSave;
}
Also used : ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) 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