Search in sources :

Example 11 with ExportChoice

use of org.talend.repository.ui.wizards.exportjob.scriptsmanager.JobScriptsManager.ExportChoice in project tdi-studio-se by Talend.

the class JobScriptsExportWizardPage method buildJobWithMaven.

protected boolean buildJobWithMaven(JobExportType jobExportType, IProgressMonitor monitor) {
    String context = (contextCombo == null || contextCombo.isDisposed()) ? processItem.getProcess().getDefaultContext() : contextCombo.getText();
    try {
        String destination = getDestinationValue();
        int separatorIndex = destination.lastIndexOf(File.separator);
        if (separatorIndex == -1) {
            //$NON-NLS-1$
            String userDir = System.getProperty("user.dir");
            destination = userDir + File.separator + destination;
        }
        Map<ExportChoice, Object> exportChoiceMap = getExportChoiceMap();
        exportChoiceMap.put(ExportChoice.addStatistics, Boolean.TRUE);
        return BuildJobManager.getInstance().buildJobs(destination, Arrays.asList(getCheckNodes()), getDefaultFileName(), getSelectedJobVersion(), context, exportChoiceMap, jobExportType, monitor);
    } catch (Exception e) {
        MessageBoxExceptionHandler.process(e, getShell());
        return false;
    }
}
Also used : IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ExportChoice(org.talend.repository.ui.wizards.exportjob.scriptsmanager.JobScriptsManager.ExportChoice) Point(org.eclipse.swt.graphics.Point) InvocationTargetException(java.lang.reflect.InvocationTargetException) IOException(java.io.IOException)

Example 12 with ExportChoice

use of org.talend.repository.ui.wizards.exportjob.scriptsmanager.JobScriptsManager.ExportChoice in project tdi-studio-se by Talend.

the class JavaJobScriptsExportWSWizardPage method createJobScriptsManager.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.repository.ui.wizards.exportjob.JavaJobScriptsExportWizardPage#createJobScriptsManager()
     */
@Override
public JobScriptsManager createJobScriptsManager() {
    Map<ExportChoice, Object> exportChoiceMap = getExportChoiceMap();
    String log4jLevel = "";
    String launcher = (getCurrentExportType1() == JobExportType.POJO) ? launcherCombo.getText() : "all";
    String context = (contextCombo == null || contextCombo.isDisposed()) ? IContext.DEFAULT : contextCombo.getText();
    JobScriptsManager manager = JobScriptsManagerFactory.createManagerInstance(exportChoiceMap, context, launcher, IProcessor.NO_STATISTICS, IProcessor.NO_TRACES, getCurrentExportType1());
    manager.setDestinationPath(getDestinationValue());
    if (log4jLevelCombo != null && !log4jLevelCombo.isDisposed()) {
        if (log4jLevelCombo.isEnabled()) {
            log4jLevel = log4jLevelCombo.getText();
        } else {
            log4jLevel = null;
        }
    } else {
        log4jLevel = null;
    }
    manager.setLog4jLevel(log4jLevel);
    return manager;
}
Also used : JobScriptsManager(org.talend.repository.ui.wizards.exportjob.scriptsmanager.JobScriptsManager) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ExportChoice(org.talend.repository.ui.wizards.exportjob.scriptsmanager.JobScriptsManager.ExportChoice)

Example 13 with ExportChoice

use of org.talend.repository.ui.wizards.exportjob.scriptsmanager.JobScriptsManager.ExportChoice in project tdi-studio-se by Talend.

the class StandardJobStandaloneBuildProvider method createBuildExportHandler.

@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 BuildJobHandler((ProcessItem) item, version.toString(), contextGroup.toString(), (Map<ExportChoice, Object>) choiceOption);
    return buildHandler;
}
Also used : ProcessItem(org.talend.core.model.properties.ProcessItem) IBuildJobHandler(org.talend.core.runtime.process.IBuildJobHandler) BuildJobHandler(org.talend.repository.ui.wizards.exportjob.handler.BuildJobHandler) IBuildJobHandler(org.talend.core.runtime.process.IBuildJobHandler) ExportChoice(org.talend.repository.ui.wizards.exportjob.scriptsmanager.JobScriptsManager.ExportChoice) Map(java.util.Map)

Example 14 with ExportChoice

use of org.talend.repository.ui.wizards.exportjob.scriptsmanager.JobScriptsManager.ExportChoice in project tdi-studio-se by Talend.

the class ExportProcessorHelper method export.

/**
     * 
     * DOC ggu Comment method "export".
     *
     * export for execute or deploy the job on job server.
     */
public void export(IProgressMonitor monitor, ProcessItem item, ERepositoryObjectType type, String context, String archiveFile, String log4jLevel, boolean applyContextToChildren, int statisticsPort, int tracePort, Properties properties) throws ProcessorException {
    if (item == null) {
        throw new ProcessorException("Can't find the job");
    }
    if (monitor == null) {
        monitor = new NullProgressMonitor();
    }
    // old way
    // export(destDir, archiveFileName, context, log4jLevel, applyContextToChildren, statisticsPort, tracePort,
    // statisticsPort > IProcessor.NO_STATISTICS, name, version, null, false, false, false);
    // mostly, should same as BuildJobExecuteCommand
    Map<ExportChoice, Object> exportChoiceMap = JobScriptsManagerFactory.getDefaultExportChoiceMap();
    exportChoiceMap.put(ExportChoice.doNotCompileCode, false);
    exportChoiceMap.put(ExportChoice.needDependencies, true);
    exportChoiceMap.put(ExportChoice.addStatistics, (statisticsPort > IProcessor.NO_STATISTICS));
    exportChoiceMap.put(ExportChoice.addTracs, (tracePort > IProcessor.NO_TRACES));
    exportChoiceMap.put(ExportChoice.needAntScript, false);
    exportChoiceMap.put(ExportChoice.needMavenScript, false);
    exportChoiceMap.put(ExportChoice.applyToChildren, applyContextToChildren);
    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, log4jLevel != null);
    exportChoiceMap.put(ExportChoice.log4jLevel, log4jLevel);
    // set like the method export(...) for buildJob
    exportChoiceMap.put(ExportChoice.jobType, type);
    if (context == null) {
        context = item.getProcess().getDefaultContext();
    }
    exportChoiceMap.put(ExportChoice.contextName, context);
    // add some other addition arguments in "properties"
    Properties prop = new Properties();
    if (properties != null) {
        // add init properties.
        Enumeration<Object> keys = properties.keys();
        while (keys.hasMoreElements()) {
            String key = keys.nextElement().toString();
            String value = properties.getProperty(key);
            prop.put(key, value);
        }
    }
    // prop.put(TalendProcessArgumentConstant.ARG_PORT_STATS, statisticsPort);
    // prop.put(TalendProcessArgumentConstant.ARG_PORT_TRACS, tracePort);
    exportChoiceMap.put(ExportChoice.properties, prop);
    if (monitor.isCanceled()) {
        throw new ProcessorException(new InterruptedException());
    }
    try {
        BuildJobManager.getInstance().buildJob(archiveFile, item, item.getProperty().getVersion(), context, exportChoiceMap, JobExportType.POJO, monitor);
    } catch (InvocationTargetException e) {
        if (e.getTargetException() != null) {
            throw new ProcessorException(e.getTargetException());
        } else {
            throw new ProcessorException(e);
        }
    } catch (Exception e) {
        throw new ProcessorException(e);
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ProcessorException(org.talend.designer.runprocess.ProcessorException) ExportChoice(org.talend.repository.ui.wizards.exportjob.scriptsmanager.JobScriptsManager.ExportChoice) Properties(java.util.Properties) InvocationTargetException(java.lang.reflect.InvocationTargetException) ProcessorException(org.talend.designer.runprocess.ProcessorException) IOException(java.io.IOException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 15 with ExportChoice

use of org.talend.repository.ui.wizards.exportjob.scriptsmanager.JobScriptsManager.ExportChoice in project tmdm-studio-se by Talend.

the class DeployOnMDMExportWizardPage method prepareProcess.

private boolean prepareProcess(boolean needContextScript, String context, IProgressMonitor monitor) {
    monitor.setTaskName(Messages.DeployOnMDMExportWizardPage_prepareDeployJob);
    monitor.worked(W_PREPARE_PROCESS);
    Map<ExportChoice, Object> exportChoiceMap = getExportChoiceMap(needContextScript);
    boolean canExport = false;
    for (ExportChoice choice : ExportChoice.values()) {
        if (exportChoiceMap.get(choice) != null && exportChoiceMap.get(choice) instanceof Boolean && (Boolean) exportChoiceMap.get(choice)) {
            canExport = true;
            break;
        }
    }
    if (!canExport) {
        Display.getDefault().asyncExec(new Runnable() {

            public void run() {
                MessageDialog.openInformation(getContainer().getShell(), Messages.DeployOnMDMExportWizardPage_publishResourceError, Messages.DeployOnMDMExportWizardPage_chooseResource);
            }
        });
        setDeploySucceed(false);
        return false;
    }
    // reset the manager,now only support zip type
    manager = new JobJavaScriptsManager(exportChoiceMap, context, JobScriptsManager.ALL_ENVIRONMENTS, IProcessor.NO_STATISTICS, IProcessor.NO_TRACES);
    if (!saveflag) {
        saveflag = true;
        return false;
    }
    // about to invoke the operation so save our state
    doSaveWidgetValues();
    monitor.worked(W_PREPARE_PROCESS);
    return true;
}
Also used : IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ExportChoice(org.talend.repository.ui.wizards.exportjob.scriptsmanager.JobScriptsManager.ExportChoice)

Aggregations

ExportChoice (org.talend.repository.ui.wizards.exportjob.scriptsmanager.JobScriptsManager.ExportChoice)18 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)10 File (java.io.File)7 ProcessItem (org.talend.core.model.properties.ProcessItem)7 IOException (java.io.IOException)6 ProcessorException (org.talend.designer.runprocess.ProcessorException)6 InvocationTargetException (java.lang.reflect.InvocationTargetException)4 EnumMap (java.util.EnumMap)4 Map (java.util.Map)4 IFile (org.eclipse.core.resources.IFile)4 IBuildJobHandler (org.talend.core.runtime.process.IBuildJobHandler)4 ExportFileResource (org.talend.repository.documentation.ExportFileResource)4 HashMap (java.util.HashMap)3 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)3 PersistenceException (org.talend.commons.exception.PersistenceException)3 JobScriptsManager (org.talend.repository.ui.wizards.exportjob.scriptsmanager.JobScriptsManager)3 URL (java.net.URL)2 Properties (java.util.Properties)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 Test (org.junit.Test)2