Search in sources :

Example 1 with BuildDataServiceHandler

use of org.talend.repository.services.export.BuildDataServiceHandler 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;
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IFile(org.eclipse.core.resources.IFile) HashMap(java.util.HashMap) IRunProcessService(org.talend.designer.runprocess.IRunProcessService) ExportChoice(org.talend.repository.ui.wizards.exportjob.scriptsmanager.JobScriptsManager.ExportChoice) BuildDataServiceHandler(org.talend.repository.services.export.BuildDataServiceHandler) SubProgressMonitor(org.eclipse.core.runtime.SubProgressMonitor) ITalendProcessJavaProject(org.talend.core.runtime.process.ITalendProcessJavaProject) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IFile(org.eclipse.core.resources.IFile) File(java.io.File)

Aggregations

File (java.io.File)1 HashMap (java.util.HashMap)1 IFile (org.eclipse.core.resources.IFile)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 SubProgressMonitor (org.eclipse.core.runtime.SubProgressMonitor)1 ITalendProcessJavaProject (org.talend.core.runtime.process.ITalendProcessJavaProject)1 IRunProcessService (org.talend.designer.runprocess.IRunProcessService)1 BuildDataServiceHandler (org.talend.repository.services.export.BuildDataServiceHandler)1 ExportChoice (org.talend.repository.ui.wizards.exportjob.scriptsmanager.JobScriptsManager.ExportChoice)1