use of org.talend.designer.runprocess.IRunProcessService in project tesb-studio-se by Talend.
the class CreateMavenBundlePom method getProcessor.
public static IProcessor getProcessor(JobInfo jobInfo) {
if (jobInfo.getProcessor() != null) {
return jobInfo.getProcessor();
}
IProcess process = null;
ProcessItem processItem;
processItem = jobInfo.getProcessItem();
if (processItem == null && jobInfo.getJobVersion() == null) {
processItem = ItemCacheManager.getProcessItem(jobInfo.getJobId());
}
if (processItem == null && jobInfo.getJobVersion() != null) {
processItem = ItemCacheManager.getProcessItem(jobInfo.getJobId(), jobInfo.getJobVersion());
}
if (processItem == null && jobInfo.getProcess() == null) {
return null;
}
if (jobInfo.getProcess() == null) {
if (processItem != null) {
IDesignerCoreService service = CorePlugin.getDefault().getDesignerCoreService();
process = service.getProcessFromProcessItem(processItem);
if (process instanceof IProcess2) {
((IProcess2) process).setProperty(processItem.getProperty());
}
}
if (process == null) {
return null;
}
} else {
process = jobInfo.getProcess();
}
Property curProperty = processItem.getProperty();
if (processItem.getProperty() == null && process instanceof IProcess2) {
curProperty = ((IProcess2) process).getProperty();
}
IRunProcessService service = CorePlugin.getDefault().getRunProcessService();
IProcessor processor = service.createCodeProcessor(process, curProperty, ((RepositoryContext) CorePlugin.getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY)).getProject().getLanguage(), true);
jobInfo.setProcessor(processor);
return processor;
}
use of org.talend.designer.runprocess.IRunProcessService in project tesb-studio-se by Talend.
the class JavaCamelJobScriptsExportWSAction method run.
@Override
public final void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
this.monitor = monitor;
String groupId = getGroupId();
String routeName = getArtifactId();
String routeVersion = getArtifactVersion();
// FIXME temporary solution for TESB-27587, in case of artivact id is diff with parent route name
// if (CommonUIPlugin.isFullyHeadless()) {
// try {
// String artifactId = RouteArtifactId.get();
// if (artifactId == null) {
// RouteArtifactId.set(routeName);
// // getProcessItem().getProperty().setLabel(routeName);
// } else {
// routeName = RouteArtifactId.get();
// }
// } catch (Exception e) {
// }
// }
// FIXME temporary solution, should be replaced by proper handling
// of MicroService vs. KAR build.
boolean isCreatingMicroService = false;
Boolean oldMS = RouteProcessingExchange.isCreatingMicroService.get();
RouteProcessingExchange.isCreatingMicroService.set(Boolean.FALSE);
try {
prepareJobBuild();
Boolean isMS = RouteProcessingExchange.isCreatingMicroService.get();
if (isMS != null) {
isCreatingMicroService = isMS.booleanValue();
}
} catch (Exception e) {
throw new InvocationTargetException(e);
} finally {
RouteProcessingExchange.isCreatingMicroService.set(oldMS);
if (oldMS == null) {
RouteProcessingExchange.resetMavenOffline();
}
}
// FIXME may require some further actions to get all POMs.
if (ProcessorUtilities.isGeneratePomOnly()) {
return;
}
featuresModel = new FeaturesModel(groupId, routeName, routeVersion);
try {
File routeFile;
try {
// $NON-NLS-1$
routeFile = File.createTempFile("route", FileConstants.JAR_FILE_SUFFIX, new File(getTempDir()));
addBuildArtifact(routeObject, "jar", routeFile);
} catch (IOException e) {
throw new InvocationTargetException(e);
}
BundleModel routeModel = new BundleModel(groupId, routeName, routeVersion, routeFile);
final ProcessItem routeProcess = (ProcessItem) routeObject.getProperty().getItem();
if (featuresModel.addBundle(routeModel)) {
CamelFeatureUtil.addFeatureAndBundles(routeProcess, featuresModel);
featuresModel.setConfigName(routeObject.getLabel());
featuresModel.setContexts(JobContextUtils.getContextsMap(routeProcess));
exportAllReferenceJobs(routeName, routeProcess);
final Set<String> routelets = new HashSet<>();
exportAllReferenceRoutelets(routeName, routeProcess, routelets);
routeVersion = routeVersion.replace("-", ".");
exportRouteBundle(routeObject, routeFile, version, null, null, routeVersion, null, routelets, null);
}
try {
if (destinationKar != null) {
// FIXME should be replaced by proper handling of
// microservice vs. KAR creation.
String dest = destinationKar;
int suffixNdx = dest.length() - 4;
String suffix = "kar";
if (isCreatingMicroService) {
if (dest.regionMatches(true, suffixNdx, ".kar", 0, 4)) {
dest = dest.substring(0, suffixNdx) + ".jar";
suffix = "jar";
} else if (dest.regionMatches(true, suffixNdx, ".zip", 0, 4)) {
suffix = "zip";
}
} else {
if (dest.regionMatches(true, suffixNdx, ".zip", 0, 4)) {
Boolean isZip = (Boolean) manager.getExportChoice().get(ExportChoice.needMavenScript);
if (isZip == null || !isZip.booleanValue()) {
dest = dest.substring(0, suffixNdx) + ".kar";
}
}
}
addBuildArtifact(routeObject, suffix, new File(dest));
}
IRunProcessService runProcessService = CorePlugin.getDefault().getRunProcessService();
ITalendProcessJavaProject talendProcessJavaProject = runProcessService.getTalendJobJavaProject(routeObject.getProperty());
FilesUtils.copyFile(featuresModel.getContent(), new File(talendProcessJavaProject.getBundleResourcesFolder().getLocation().toOSString() + File.separator + "feature.xml"));
// Build project and collect build artifacts
try {
buildJob();
} catch (Exception ex) {
throw new InvocationTargetException(ex);
}
collectBuildArtifacts();
} catch (Exception e) {
e.printStackTrace();
}
processResults(featuresModel, monitor);
} finally {
// remove generated files
removeTempFiles();
}
}
use of org.talend.designer.runprocess.IRunProcessService in project tesb-studio-se by Talend.
the class RouteJavaScriptOSGIForESBManager method addResources.
// Add Route Resource http://jira.talendforge.org/browse/TESB-6227
@Override
protected void addResources(ExportFileResource osgiResource, ProcessItem processItem) throws Exception {
IFolder srcFolder = null;
if (GlobalServiceRegister.getDefault().isServiceRegistered(IRunProcessService.class)) {
IRunProcessService processService = GlobalServiceRegister.getDefault().getService(IRunProcessService.class);
ITalendProcessJavaProject talendProcessJavaProject = processService.getTalendJobJavaProject(processItem.getProperty());
if (talendProcessJavaProject != null) {
srcFolder = talendProcessJavaProject.getExternalResourcesFolder();
}
}
if (srcFolder == null) {
return;
}
IPath srcPath = srcFolder.getLocation();
// http://jira.talendforge.org/browse/TESB-6437
// https://jira.talendforge.org/browse/TESB-7893
Collection<IPath> routeResource = RouteResourceUtil.synchronizeRouteResource(processItem);
if (routeResource != null) {
for (IPath path : RouteResourceUtil.synchronizeRouteResource(processItem)) {
osgiResource.addResource(path.removeLastSegments(1).makeRelativeTo(srcPath).toString(), path.toFile().toURI().toURL());
}
}
}
use of org.talend.designer.runprocess.IRunProcessService in project tesb-studio-se by Talend.
the class CamelNewBeanWizard method refreshLibrariesListForTheBean.
private void refreshLibrariesListForTheBean() {
GlobalServiceRegister globalServiceRegister = GlobalServiceRegister.getDefault();
if (globalServiceRegister.isServiceRegistered(IRunProcessService.class)) {
IRunProcessService runProcessService = globalServiceRegister.getService(IRunProcessService.class);
MavenPomSynchronizer.addChangeLibrariesListener();
runProcessService.updateLibraries((RoutineItem) beanItem.getProperty().getItem());
}
}
Aggregations