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;
}
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;
}
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;
}
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));
}
}
}
}
}
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;
}
Aggregations