use of org.talend.camel.designer.ui.wizards.actions.JavaCamelJobScriptsExportWithMavenAction in project tesb-studio-se by Talend.
the class JavaCamelJobScriptsExportWSWizardPage method finish.
@Override
public boolean finish() {
String version = getSelectedJobVersion();
String destinationKar = getDestinationValue();
JavaCamelJobScriptsExportWSAction action = null;
IRunnableWithProgress buildJobHandlerAction = null;
Map<ExportChoice, Object> exportChoiceMap = getExportChoiceMap();
boolean needMavenScript = false;
if (needMavenScript && destinationKar.regionMatches(true, destinationKar.length() - 4, ".kar", 0, 4)) {
destinationKar = destinationKar.substring(0, destinationKar.length() - 3) + "zip";
}
if (exportAsZip) {
exportChoiceMap.put(ExportChoice.needAssembly, Boolean.TRUE);
}
if (new File(destinationKar).exists() && !exportTypeCombo.getText().equals(EXPORTTYPE_SPRING_BOOT_DOCKER_IMAGE)) {
boolean yes = MessageDialog.openQuestion(getShell(), Messages.getString("JavaCamelJobScriptsExportWSWizardPage.OverwriteKarTitle"), Messages.getString("JavaCamelJobScriptsExportWSWizardPage.OverwriteKarMessage"));
if (!yes) {
return false;
}
} else if (!exportTypeCombo.getText().equals(EXPORTTYPE_KAR)) {
exportChoiceMap.put(ExportChoice.needAssembly, Boolean.FALSE);
}
if (exportTypeCombo.getText().equals(EXPORTTYPE_SPRING_BOOT) || exportTypeCombo.getText().equals(EXPORTTYPE_SPRING_BOOT_DOCKER_IMAGE)) {
IRunnableWithProgress worker = new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
buildJobWithMaven(exportTypeCombo.getText().equals(EXPORTTYPE_SPRING_BOOT) ? JobExportType.ROUTE : JobExportType.MSESB_IMAGE, monitor);
}
};
try {
getContainer().run(false, true, worker);
} catch (Exception e) {
MessageBoxExceptionHandler.process(e.getCause() == null ? e : e.getCause(), getShell());
return false;
}
} else {
if (getProcessItem() instanceof CamelProcessItem) {
CamelProcessItem camelProcessItem = (CamelProcessItem) getProcessItem();
if (camelProcessItem.isExportMicroService()) {
camelProcessItem.setExportMicroService(false);
}
}
if (needMavenScript) {
action = new JavaCamelJobScriptsExportWithMavenAction(exportChoiceMap, nodes[0], version, destinationKar, false);
} else {
exportChoiceMap.put(ExportChoice.esbExportType, "kar");
buildJobHandlerAction = new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
IBuildJobHandler buildJobHandler = BuildJobFactory.createBuildJobHandler(getProcessItem(), getContextName(), version, exportChoiceMap, "ROUTE");
Map<String, Object> prepareParams = new HashMap<String, Object>();
prepareParams.put(IBuildResourceParametes.OPTION_ITEMS, true);
prepareParams.put(IBuildResourceParametes.OPTION_ITEMS_DEPENDENCIES, true);
try {
buildJobHandler.prepare(monitor, prepareParams);
buildJobHandler.build(monitor);
IFile targetFile = buildJobHandler.getJobTargetFile();
if (targetFile != null && targetFile.exists()) {
try {
FilesUtils.copyFile(targetFile.getLocation().toFile(), new File(getDestinationValue()));
} catch (IOException e) {
e.printStackTrace();
}
}
} catch (Exception e) {
MessageBoxExceptionHandler.process(e.getCause() == null ? e : e.getCause(), getShell());
}
}
};
ProcessorUtilities.setExportAsOSGI(true);
}
try {
if (needMavenScript) {
getContainer().run(false, true, action);
} else {
getContainer().run(false, true, buildJobHandlerAction);
}
} catch (Exception e) {
MessageBoxExceptionHandler.process(e.getCause(), getShell());
return false;
}
}
return true;
}
Aggregations