use of org.talend.repository.ui.wizards.exportjob.scriptsmanager.JobScriptsManager.ExportChoice in project tdi-studio-se by Talend.
the class AbstractJavaProcessor method buildExportZip.
protected String buildExportZip(ProcessItem processItem, IProgressMonitor progressMonitor) throws ProcessorException {
Map<ExportChoice, Object> exportChoiceMap = JobScriptsManagerFactory.getDefaultExportChoiceMap();
exportChoiceMap.put(ExportChoice.needLauncher, false);
exportChoiceMap.put(ExportChoice.needJobItem, true);
// exportChoiceMap.put(ExportChoice.needJobScript, true); //?? for old build? no need
if (CommonsPlugin.isDebugMode()) {
exportChoiceMap.put(ExportChoice.needSourceCode, true);
} else {
exportChoiceMap.put(ExportChoice.needSourceCode, false);
}
exportChoiceMap.put(ExportChoice.binaries, true);
exportChoiceMap.put(ExportChoice.includeLibs, true);
exportChoiceMap.put(ExportChoice.needAssembly, true);
if (progressMonitor.isCanceled()) {
throw new ProcessorException(new InterruptedException());
}
final String archiveFilePath = Path.fromOSString(CorePlugin.getDefault().getPreferenceStore().getString(ITalendCorePrefConstants.FILE_PATH_TEMP)).append(getFilePathPrefix() + '_' + process.getName() + FileExtensions.ZIP_FILE_SUFFIX).toString();
try {
exportChoiceMap.put(ExportChoice.needContext, true);
String contextName = processItem.getProcess().getDefaultContext();
exportChoiceMap.put(ExportChoice.contextName, contextName);
buildJob(archiveFilePath, processItem, processItem.getProperty().getVersion(), contextName, exportChoiceMap, JobExportType.POJO, progressMonitor);
} catch (Exception e) {
throw new ProcessorException(e);
} finally {
ProcessorUtilities.resetExportConfig();
}
return archiveFilePath;
}
use of org.talend.repository.ui.wizards.exportjob.scriptsmanager.JobScriptsManager.ExportChoice in project tdi-studio-se by Talend.
the class ExportProcessorHelper method exportPigudf.
public void exportPigudf(IProcessor processor, Property property, int statisticsPort, int tracePort) throws ProcessorException {
// build java project
CorePlugin.getDefault().getRunProcessService().buildJavaProject();
Map<ExportChoice, Object> exportChoiceMap = new EnumMap<ExportChoice, Object>(ExportChoice.class);
exportChoiceMap.put(ExportChoice.needPigudf, true);
ProcessItem processItem = (ProcessItem) property.getItem();
ExportFileResource fileResource = new ExportFileResource(processItem, property.getLabel());
ExportFileResource[] exportFileResources = new ExportFileResource[] { fileResource };
JobScriptsManager jobScriptsManager = JobScriptsManagerFactory.createManagerInstance(exportChoiceMap, processor.getContext().getName(), JobScriptsManager.ALL_ENVIRONMENTS, statisticsPort, tracePort, JobExportType.POJO);
URL url = jobScriptsManager.getExportPigudfResources(exportFileResources);
if (url == null) {
return;
}
File file = new File(url.getFile());
File libFolder = JavaProcessorUtilities.getJavaProjectLibFolder();
if (libFolder == null) {
return;
}
File target = new File(libFolder.getAbsolutePath() + property.getLabel() + "_" + property.getVersion() + "_" + file.getName());
try {
FilesUtils.copyFile(file, target);
} catch (IOException e) {
throw new ProcessorException(e.getMessage());
}
}
use of org.talend.repository.ui.wizards.exportjob.scriptsmanager.JobScriptsManager.ExportChoice in project tesb-studio-se by Talend.
the class RouteOSGiBundleBuildProvider method createBuildExportHandler.
/* (non-Javadoc)
* @see org.talend.core.runtime.repository.build.AbstractBuildProvider#createBuildExportHandler(java.util.Map)
*/
@Override
public IBuildExportHandler createBuildExportHandler(Map<String, Object> parameters) {
if (parameters == null || parameters.isEmpty()) {
return null;
}
final Object item = parameters.get(ITEM);
if (item == null || !(item instanceof ProcessItem)) {
return null;
}
final Object version = parameters.get(VERSION);
if (version == null) {
return null;
}
final Object contextGroup = parameters.get(CONTEXT_GROUP);
if (contextGroup == null) {
return null;
}
Object choiceOption = parameters.get(CHOICE_OPTION);
if (choiceOption == null) {
choiceOption = Collections.emptyMap();
}
if (!(choiceOption instanceof Map)) {
return null;
}
IBuildJobHandler buildHandler = new BuildBundleHandler((ProcessItem) item, version.toString(), contextGroup.toString(), (Map<ExportChoice, Object>) choiceOption);
return buildHandler;
}
use of org.talend.repository.ui.wizards.exportjob.scriptsmanager.JobScriptsManager.ExportChoice in project tesb-studio-se by Talend.
the class ServiceExportWizard method performFinish.
@Override
public boolean performFinish() {
final String destinationValue = mainPage.getDestinationValue();
// TESB-7319: add confirm dialog
if (new File(destinationValue).exists()) {
boolean openQuestion = MessageDialog.openQuestion(getShell(), Messages.ServiceExportWizard_destinationExistTitle, Messages.ServiceExportWizard_destinationExistMessage);
if (!openQuestion) {
return false;
}
}
// END TESB-7319
Map<ExportChoice, Object> exportChoiceMap = mainPage.getExportChoiceMap();
exportChoiceMap.put(ExportChoice.doNotCompileCode, false);
exportChoiceMap.put(ExportChoice.needDependencies, false);
exportChoiceMap.put(ExportChoice.addStatistics, false);
exportChoiceMap.put(ExportChoice.addTracs, false);
exportChoiceMap.put(ExportChoice.needAntScript, false);
exportChoiceMap.put(ExportChoice.needMavenScript, false);
exportChoiceMap.put(ExportChoice.applyToChildren, false);
exportChoiceMap.put(ExportChoice.needContext, true);
exportChoiceMap.put(ExportChoice.binaries, true);
exportChoiceMap.put(ExportChoice.needSourceCode, false);
exportChoiceMap.put(ExportChoice.executeTests, false);
exportChoiceMap.put(ExportChoice.includeTestSource, false);
exportChoiceMap.put(ExportChoice.includeLibs, true);
exportChoiceMap.put(ExportChoice.needLog4jLevel, false);
exportChoiceMap.put(ExportChoice.needAssembly, true);
String bundleVersion = PomIdsHelper.getJobVersion(serviceItem.getProperty());
if (bundleVersion != null) {
bundleVersion = bundleVersion.replace("-", ".");
}
exportChoiceMap.put(ExportChoice.bundleVersion, bundleVersion);
// update to use BuildDataServiceHandler
IProgressMonitor pMonitor = new NullProgressMonitor();
int scale = 10;
BuildDataServiceHandler buildServiceHandler = new BuildDataServiceHandler(serviceItem, serviceItem.getProperty().getVersion(), IContext.DEFAULT, exportChoiceMap);
Map<String, Object> prepareParams = new HashMap<String, Object>();
prepareParams.put(IBuildResourceParametes.OPTION_ITEMS, true);
prepareParams.put(IBuildResourceParametes.OPTION_ITEMS_DEPENDENCIES, true);
try {
buildServiceHandler.prepare(pMonitor, prepareParams);
buildServiceHandler.build(new SubProgressMonitor(pMonitor, scale));
IFile serviceTargetFile = buildServiceHandler.getJobTargetFile();
if (serviceTargetFile != null && serviceTargetFile.exists()) {
FilesUtils.copyFile(serviceTargetFile.getLocation().toFile(), new File(destinationValue));
} else {
if (GlobalServiceRegister.getDefault().isServiceRegistered(IRunProcessService.class)) {
IRunProcessService service = (IRunProcessService) GlobalServiceRegister.getDefault().getService(IRunProcessService.class);
ITalendProcessJavaProject talendJavaProject = service.getTalendJobJavaProject(serviceItem.getProperty());
String mvnLogFilePath = // $NON-NLS-1$
talendJavaProject.getProject().getFile("lastGenerated.log").getLocation().toPortableString();
Exception e = new Exception("Service was not built successfully, please check the logs for more details available on " + mvnLogFilePath);
MessageBoxExceptionHandler.process(e, getShell());
}
return false;
}
} catch (Exception e) {
MessageBoxExceptionHandler.process(e, getShell());
BuildCacheManager.getInstance().performBuildFailure();
return false;
} finally {
ProcessorUtilities.resetExportConfig();
}
mainPage.finish();
return true;
}
use of org.talend.repository.ui.wizards.exportjob.scriptsmanager.JobScriptsManager.ExportChoice in project tesb-studio-se by Talend.
the class ExportServiceActionTest method testRun.
/**
* Test method for
* {@link org.talend.repository.services.ui.action.ExportServiceAction#run(org.eclipse.core.runtime.IProgressMonitor)}
* .
*/
@Test
public void testRun() {
Map<ExportChoice, Object> exportChoiceMap = new EnumMap<ExportChoice, Object>(ExportChoice.class);
exportChoiceMap.put(ExportChoice.needLauncher, true);
exportChoiceMap.put(ExportChoice.needSystemRoutine, true);
exportChoiceMap.put(ExportChoice.needUserRoutine, true);
exportChoiceMap.put(ExportChoice.needTalendLibraries, true);
exportChoiceMap.put(ExportChoice.needJobItem, true);
exportChoiceMap.put(ExportChoice.needJobScript, true);
exportChoiceMap.put(ExportChoice.needContext, true);
exportChoiceMap.put(ExportChoice.needSourceCode, true);
exportChoiceMap.put(ExportChoice.applyToChildren, false);
exportChoiceMap.put(ExportChoice.doNotCompileCode, false);
exportChoiceMap.put(ExportChoice.needMavenScript, false);
ServiceItem serviceItem = ServicesFactory.eINSTANCE.createServiceItem();
Property property = PropertiesFactory.eINSTANCE.createProperty();
property.setLabel("testSvr");
serviceItem.setProperty(property);
ItemState state = PropertiesFactory.eINSTANCE.createItemState();
serviceItem.setState(state);
ServiceConnection connection = ServicesFactoryImpl.eINSTANCE.createServiceConnection();
serviceItem.setConnection(connection);
try {
File fileName = File.createTempFile("serviceExportTest", ".jar");
ExportServiceAction action = new ExportServiceAction(serviceItem, fileName.getAbsolutePath(), exportChoiceMap);
Assert.assertNotNull(action.getTmpFolderPath());
} catch (Exception e) {
e.printStackTrace();
fail("Test testRun() method failure.");
}
}
Aggregations