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