use of com.mulesoft.tools.migration.library.tools.mel.DefaultMelCompatibilityResolver in project mule-migration-assistant by mulesoft.
the class MelToDwExpressionMigrator method translateSingleExpression.
public String translateSingleExpression(String unwrappedExpression, boolean dataWeaveBodyOnly, Element element, boolean enricher) {
logger.debug(" --->> Evaluating MEL expression at element {} -> {}", element != null ? element.getName() : "null", unwrappedExpression);
String migratedExpression;
MigrationResult result;
try {
result = Migrator.migrate(unwrappedExpression);
migratedExpression = result.getGeneratedCode();
} catch (Exception e) {
return compatibilityResolver.resolve(unwrappedExpression, element, report, model, this, enricher);
}
if (result.metadata().children().exists(a -> a instanceof NonMigratable)) {
List<NonMigratable> metadata = (List<NonMigratable>) (List<?>) JavaConverters.seqAsJavaList(result.metadata().children()).stream().filter(a -> a instanceof NonMigratable).collect(toList());
metadata.forEach(a -> report.report(a.reason(), element, element));
return new DefaultMelCompatibilityResolver().resolve(unwrappedExpression, element, report, model, this, enricher);
}
if (migratedExpression.contains("message.inboundAttachments")) {
report.report("message.expressionsAttachments", element, element);
}
if (result.metadata().children().exists(a -> a instanceof JavaModuleRequired)) {
Dependency javaModuleDependency = new Dependency.DependencyBuilder().withGroupId("org.mule.module").withArtifactId("mule-java-module").withVersion(targetVersion("mule-java-module")).withClassifier("mule-plugin").build();
model.getPomModel().ifPresent(m -> m.addDependency(javaModuleDependency));
}
migratedExpression = resolveServerContext(migratedExpression);
migratedExpression = resolveIdentifiers(migratedExpression);
if (dataWeaveBodyOnly) {
migratedExpression = migratedExpression.replaceFirst("%dw 2\\.0\n---", "").trim();
}
report.melExpressionSuccess(unwrappedExpression);
return escapeUnderscores(migratedExpression);
}
use of com.mulesoft.tools.migration.library.tools.mel.DefaultMelCompatibilityResolver in project mule-migration-assistant by mulesoft.
the class DbDdlExecute method execute.
@Override
public void execute(Element object, MigrationReport report) throws RuntimeException {
migrateSql(object);
if (object.getAttribute("source") != null) {
report.report("db.source", object, object);
object.removeAttribute("source");
}
migrateOperationStructure(getApplicationModel(), object, report, false, getExpressionMigrator(), new DefaultMelCompatibilityResolver());
}
use of com.mulesoft.tools.migration.library.tools.mel.DefaultMelCompatibilityResolver in project mule-migration-assistant by mulesoft.
the class DbDelete method execute.
@Override
public void execute(Element object, MigrationReport report) throws RuntimeException {
migrateSql(object);
if ("true".equals(object.getAttributeValue("bulkMode"))) {
object.setName("bulk-delete");
object.removeAttribute("bulkMode");
migrateBulkInputParams(object);
} else {
List<Element> paramTypes = object.getChildren("in-param", DB_NAMESPACE).stream().filter(ip -> ip.getAttribute("type") != null).map(ip -> new Element("parameter-type", DB_NAMESPACE).setAttribute("key", ip.getAttributeValue("name")).setAttribute("type", ip.getAttributeValue("type"))).collect(toList());
if (!paramTypes.isEmpty()) {
object.addContent(new Element("parameter-types", DB_NAMESPACE).addContent(paramTypes));
}
migrateInputParams(object);
}
if (object.getAttribute("source") != null) {
report.report("db.source", object, object);
object.removeAttribute("source");
}
migrateOperationStructure(getApplicationModel(), object, report, false, getExpressionMigrator(), new DefaultMelCompatibilityResolver());
}
use of com.mulesoft.tools.migration.library.tools.mel.DefaultMelCompatibilityResolver in project mule-migration-assistant by mulesoft.
the class DbExecute method execute.
@Override
public void execute(Element object, MigrationReport report) throws RuntimeException {
object.setName("execute-script");
if (object.getAttribute("file") == null) {
String sql = getExpressionMigrator().migrateExpression(object.getText(), true, object);
object.removeContent();
object.addContent(setText(new Element("sql", DB_NAMESPACE), getExpressionMigrator().migrateExpression(sql, true, object)));
}
if (object.getAttribute("source") != null) {
report.report("db.source", object, object);
object.removeAttribute("source");
}
migrateOperationStructure(getApplicationModel(), object, report, false, getExpressionMigrator(), new DefaultMelCompatibilityResolver());
}
use of com.mulesoft.tools.migration.library.tools.mel.DefaultMelCompatibilityResolver in project mule-migration-assistant by mulesoft.
the class DbInsert method execute.
@Override
public void execute(Element object, MigrationReport report) throws RuntimeException {
migrateSql(object);
if ("true".equals(object.getAttributeValue("bulkMode"))) {
object.setName("bulk-insert");
object.removeAttribute("bulkMode");
migrateBulkInputParams(object);
} else {
migrateInputParamTypes(object);
migrateInputParams(object);
}
if (object.getAttribute("autoGeneratedKeysColumnIndexes") != null) {
object.addContent(new Element("auto-generated-keys-column-indexes", DB_NAMESPACE).addContent(new Element("auto-generated-keys-column-index", DB_NAMESPACE).setAttribute("value", object.getAttributeValue("autoGeneratedKeysColumnIndexes"))));
object.removeAttribute("autoGeneratedKeysColumnIndexes");
}
if (object.getAttribute("autoGeneratedKeysColumnNames") != null) {
object.addContent(new Element("auto-generated-keys-column-names", DB_NAMESPACE).addContent(new Element("auto-generated-keys-column-name", DB_NAMESPACE).setAttribute("value", object.getAttributeValue("autoGeneratedKeysColumnNames"))));
object.removeAttribute("autoGeneratedKeysColumnNames");
}
if (object.getAttribute("source") != null) {
report.report("db.source", object, object);
object.removeAttribute("source");
}
migrateOperationStructure(getApplicationModel(), object, report, false, getExpressionMigrator(), new DefaultMelCompatibilityResolver());
}
Aggregations