Search in sources :

Example 6 with MigrationReportRecorder

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

the class UpdateRoutinesLibrariesMigrationTask method migrateCamelCore.

private void migrateCamelCore(RoutineItem routineItem) {
    EList imports = routineItem.getImports();
    List<ModuleNeeded> importNeedsList = ModulesNeededProvider.getModulesNeededForCamelCore();
    for (ModuleNeeded model : importNeedsList) {
        IMPORTType importTypeToAdd = ComponentFactory.eINSTANCE.createIMPORTType();
        importTypeToAdd.setMODULE(model.getModuleName());
        importTypeToAdd.setMESSAGE(model.getInformationMsg());
        importTypeToAdd.setREQUIRED(model.isRequired());
        importTypeToAdd.setMVN(model.getMavenUri());
        if (!imports.contains(importTypeToAdd)) {
            String messageAdd = String.format("Adding module needed for Routine: %s", importTypeToAdd.getMODULE());
            generateReportRecord(new MigrationReportRecorder(this, MigrationReportRecorder.MigrationOperationType.ADD, routineItem, null, messageAdd, null, null));
            imports.add(importTypeToAdd);
        } else {
            String messageAdd = String.format("Duplicate module found: %s", importTypeToAdd.getMODULE());
            generateReportRecord(new MigrationReportRecorder(this, MigrationReportRecorder.MigrationOperationType.ADD, routineItem, null, messageAdd, 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) ModuleNeeded(org.talend.core.model.general.ModuleNeeded)

Example 7 with MigrationReportRecorder

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

the class UpdateRoutinesLibrariesMigrationTask method upgradeModulesNeededForRoutines.

private boolean upgradeModulesNeededForRoutines(RoutineItem routineItem) {
    EList imports = routineItem.getImports();
    boolean migrateCamelCore = false;
    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("."));
            String prefix = fullName.substring(0, fullName.lastIndexOf('-') + 1);
            if (version != null && !version.equals(camelVersion) && (camelModuleListNew.contains(prefix) || camelModuleListOld.contains(prefix))) {
                importType.setMODULE(fullName.replaceAll(version, camelVersion));
                if (camelModuleListNew.contains(prefix)) {
                    importType.setMVN(importType.getMVN().replaceAll(groupIdOld, groupIdNew).replaceAll("-" + version + "/6.0.0", "/" + camelVersion));
                } else {
                    importType.setMVN(importType.getMVN().replaceAll(version, camelVersion));
                }
                String message = String.format("Upgrading camel routine dependency %s version from %s to %s", fullName, version, camelVersion);
                generateReportRecord(new MigrationReportRecorder(this, MigrationReportRecorder.MigrationOperationType.MODIFY, routineItem, null, message, null, null));
                if (camelCorePrefix.equals(prefix)) {
                    migrateCamelCore = true;
                }
            }
        }
    }
    return migrateCamelCore;
}
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 8 with MigrationReportRecorder

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

the class UpdatecKafkaMigrationTask method renameAdvancedParameters.

private boolean renameAdvancedParameters(NodeType currentNode) throws PersistenceException {
    boolean needSave = false;
    for (Object e : currentNode.getElementParameter()) {
        ElementParameterType p = (ElementParameterType) e;
        if ("URI_OPTIONS".equals(p.getName())) {
            for (Object v : p.getElementValue()) {
                ElementValueType ev = (ElementValueType) v;
                if ("\"kafkaHeaderSerializer\"".equalsIgnoreCase(ev.getValue()) && "NAME".equalsIgnoreCase(ev.getElementRef())) {
                    ev.setValue("\"headerSerializer\"");
                    needSave = true;
                    generateReportRecord(new MigrationReportRecorder(this, MigrationReportRecorder.MigrationOperationType.MODIFY, getRouteItem(), currentNode, "URI_OPTIONS", "\"kafkaHeaderSerializer\"", "\"headerSerializer\""));
                }
                if ("\"kafkaHeaderDeserializer\"".equalsIgnoreCase(ev.getValue()) && "NAME".equalsIgnoreCase(ev.getElementRef())) {
                    ev.setValue("\"headerDeserializer\"");
                    needSave = true;
                    generateReportRecord(new MigrationReportRecorder(this, MigrationReportRecorder.MigrationOperationType.MODIFY, getRouteItem(), currentNode, "URI_OPTIONS", "\"kafkaHeaderDeserializer\"", "\"headerDeserializer\""));
                }
            }
        }
    }
    return needSave;
}
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 9 with MigrationReportRecorder

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

the class NormalizeDataServiceJobBuildTypeMigrationTask method execute.

/*
    * (non-Javadoc)
    *
    * @see
    * org.talend.core.model.migration.AbstractDataserviceMigrationTask#execute(org
    * .talend.core.model.properties.Item)
    */
@SuppressWarnings("unchecked")
@Override
public ExecutionResult execute(Item item) {
    final ProcessType processType = getProcessType(item);
    boolean modified = false;
    for (String name : ESB_COMPONENTS) {
        IComponentFilter filter = new NameComponentFilter(name);
        List<NodeType> c = searchComponent(processType, filter);
        if (!c.isEmpty()) {
            Object buildType = item.getProperty().getAdditionalProperties().get(BUILD_TYPE_PROPERTY);
            if (BUILD_TYPE_ROUTE.equals(buildType)) {
                item.getProperty().getAdditionalProperties().put(BUILD_TYPE_PROPERTY, BUILD_TYPE_OSGI);
                try {
                    save(item);
                    modified |= true;
                    generateReportRecord(new MigrationReportRecorder(this, MigrationReportRecorder.MigrationOperationType.MODIFY, item, null, "Build Type", BUILD_TYPE_ROUTE, BUILD_TYPE_OSGI));
                } catch (PersistenceException e) {
                    ExceptionHandler.process(e);
                    return ExecutionResult.FAILURE;
                }
                return ExecutionResult.SUCCESS_NO_ALERT;
            }
        }
    }
    if (modified) {
        return ExecutionResult.SUCCESS_NO_ALERT;
    } else {
        return ExecutionResult.NOTHING_TO_DO;
    }
}
Also used : 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)

Example 10 with MigrationReportRecorder

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

the class RemoveAWSConnectionDefaultRegionMigrationTask method removeAWSConnectionDefaultRegion.

private boolean removeAWSConnectionDefaultRegion(NodeType nodeType) {
    boolean needSave = false;
    EList<ElementParameterType> list = nodeType.getElementParameter();
    for (ElementParameterType elParameter : list) {
        if ("REGION".equals(elParameter.getName()) && "DEFAULT".equals(elParameter.getValue())) {
            elParameter.setValue("\"us-east-1\"");
            needSave = true;
            String message = "Migrating DEFAULT 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)

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