Search in sources :

Example 1 with JobResourceManager

use of org.talend.core.model.repository.job.JobResourceManager in project tdi-studio-se by Talend.

the class SpagicDeployWizardPage method finish.

/**
     * The Finish button was pressed. Try to do the required work now and answer a boolean indicating success. If false
     * is returned then the wizard will not close.
     * 
     * @returns boolean
     */
@Override
public boolean finish() {
    Map<ExportChoice, Object> exportChoiceMap = getExportChoiceMap();
    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) {
        MessageDialog.openInformation(getContainer().getShell(), //$NON-NLS-1$
        Messages.getString("SpagicDeployWizardPage.exportResourceError"), //$NON-NLS-1$
        Messages.getString("SpagicDeployWizardPage.chooseResource"));
        return false;
    }
    if (!ensureTargetIsValid()) {
        return false;
    }
    manager = new //$NON-NLS-1$
    SpagicJavaDeployManager(//$NON-NLS-1$
    exportChoiceMap, //$NON-NLS-1$
    contextCombo.getText(), //$NON-NLS-1$
    "all", //$NON-NLS-1$
    IProcessor.NO_STATISTICS, IProcessor.NO_TRACES);
    String topFolder = getRootFolderName();
    List<ExportFileResource> resourcesToExport = null;
    try {
        resourcesToExport = getExportResources();
    } catch (ProcessorException e) {
        MessageBoxExceptionHandler.process(e);
        return false;
    }
    setTopFolder(resourcesToExport, topFolder);
    // Save dirty editors if possible but do not stop if not all are saved
    saveDirtyEditors();
    // about to invoke the operation so save our state
    saveWidgetValues();
    // boolean ok =executeExportOperation(new ArchiveFileExportOperationFullPath(process));
    // File file = createSapgicProperty();
    ArchiveFileExportOperationFullPath exporterOperation = getExporterOperation(resourcesToExport);
    // exportResource(topFolder, "", "", 1);
    boolean ok = executeExportOperation(exporterOperation);
    // path can like name/name
    manager.deleteTempFiles();
    ProcessorUtilities.resetExportConfig();
    String projectName = ((RepositoryContext) CorePlugin.getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY)).getProject().getLabel();
    List<JobResource> jobResources = new ArrayList<JobResource>();
    for (ExportFileResource proces : process) {
        try {
            proces.setProcess((ProcessItem) ProxyRepositoryFactory.getInstance().getUptodateProperty(proces.getItem().getProperty()).getItem());
        } catch (PersistenceException e) {
            e.printStackTrace();
        }
        ProcessItem processItem = (ProcessItem) proces.getItem();
        JobInfo jobInfo = new JobInfo(processItem, processItem.getProcess().getDefaultContext());
        jobResources.add(new JobResource(projectName, jobInfo));
        Set<JobInfo> jobInfos = ProcessorUtilities.getChildrenJobInfo(processItem);
        for (JobInfo subjobInfo : jobInfos) {
            jobResources.add(new JobResource(projectName, subjobInfo));
        }
    }
    JobResourceManager reManager = JobResourceManager.getInstance();
    for (JobResource r : jobResources) {
        if (reManager.isProtected(r)) {
            try {
                ProcessorUtilities.generateCode(r.getJobInfo().getJobId(), r.getJobInfo().getContextName(), r.getJobInfo().getJobVersion(), false, false);
            } catch (ProcessorException e) {
                ExceptionHandler.process(e);
            }
        } else {
            reManager.deleteResource(r);
        }
    }
    return ok;
}
Also used : ProcessorException(org.talend.designer.runprocess.ProcessorException) JobResource(org.talend.core.model.repository.job.JobResource) ArrayList(java.util.ArrayList) ExportChoice(org.talend.repository.ui.wizards.exportjob.scriptsmanager.JobScriptsManager.ExportChoice) ProcessItem(org.talend.core.model.properties.ProcessItem) ExportFileResource(org.talend.repository.documentation.ExportFileResource) JobInfo(org.talend.core.model.process.JobInfo) PersistenceException(org.talend.commons.exception.PersistenceException) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) JobResourceManager(org.talend.core.model.repository.job.JobResourceManager) ArchiveFileExportOperationFullPath(org.talend.core.ui.export.ArchiveFileExportOperationFullPath)

Example 2 with JobResourceManager

use of org.talend.core.model.repository.job.JobResourceManager in project tdi-studio-se by Talend.

the class JobExportAction method generatedCodes.

/**
     * DOC ggu Comment method "generatedCodes".
     * 
     * @param version
     * @param monitor
     * @param processes
     */
protected boolean generatedCodes(String version, IProgressMonitor monitor, List<ExportFileResource> processes) {
    String projectName = ((RepositoryContext) CorePlugin.getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY)).getProject().getLabel();
    List<JobResource> jobResources = new ArrayList<JobResource>();
    for (ExportFileResource process : processes) {
        ProcessItem processItem = (ProcessItem) process.getItem();
        JobInfo jobInfo = new JobInfo(processItem, processItem.getProcess().getDefaultContext(), version);
        jobResources.add(new JobResource(projectName, jobInfo));
        Set<JobInfo> jobInfos = ProcessorUtilities.getChildrenJobInfo(processItem);
        for (JobInfo subjobInfo : jobInfos) {
            jobResources.add(new JobResource(projectName, subjobInfo));
        }
    }
    JobResourceManager reManager = JobResourceManager.getInstance();
    for (JobResource r : jobResources) {
        if (reManager.isProtected(r)) {
            try {
                ProcessorUtilities.generateCode(r.getJobInfo().getJobId(), r.getJobInfo().getContextName(), r.getJobInfo().getJobVersion(), false, false, monitor);
            } catch (ProcessorException e) {
                MessageBoxExceptionHandler.process(e);
                return false;
            }
        }
    }
    return true;
}
Also used : ProcessorException(org.talend.designer.runprocess.ProcessorException) ProcessItem(org.talend.core.model.properties.ProcessItem) ExportFileResource(org.talend.repository.documentation.ExportFileResource) JobInfo(org.talend.core.model.process.JobInfo) JobResource(org.talend.core.model.repository.job.JobResource) ArrayList(java.util.ArrayList) JobResourceManager(org.talend.core.model.repository.job.JobResourceManager)

Example 3 with JobResourceManager

use of org.talend.core.model.repository.job.JobResourceManager in project tdi-studio-se by Talend.

the class AbstractMultiPageTalendEditor method refreshName.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.repository.editor.INameRefresher#refreshName()
     */
@Override
public void refreshName() {
    try {
        JobResourceManager jobResourceManager = JobResourceManager.getInstance();
        jobResourceManager.removeProtection(designerEditor);
        for (String id : designerEditor.getProtectedIds()) {
            if (designerEditor.getJobResource(id).getJobInfo().getJobName().equalsIgnoreCase(oldJobName)) {
                // delete only the job renamed
                jobResourceManager.deleteResource(designerEditor.getJobResource(id));
            }
        }
        designerEditor.resetJobResources();
        setName();
        JobInfo jobInfo = designerEditor.getCurrentJobResource().getJobInfo();
        if (jobInfo != null) {
            jobInfo.setJobName(getEditorInput().getName());
        }
        jobResourceManager.addProtection(designerEditor);
        processor.initPath();
        processor.setProcessorStates(IProcessor.STATES_EDIT);
        // modified by wzhang to fix bug 8180 in thales branding.
        if (useCodeView) {
            updateCodeEditorContent();
        }
        IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
        if (activeWorkbenchWindow != null) {
            if (activeWorkbenchWindow.getActivePage().isPartVisible(this)) {
                new ActiveProcessTracker().partBroughtToTop(this);
                DesignerPlugin.getDefault().getRunProcessService().refreshView();
            }
        }
    } catch (Exception e) {
        MessageBoxExceptionHandler.process(e);
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) JobInfo(org.talend.core.model.process.JobInfo) JobResourceManager(org.talend.core.model.repository.job.JobResourceManager) CoreException(org.eclipse.core.runtime.CoreException) PartInitException(org.eclipse.ui.PartInitException) LoginException(org.talend.commons.exception.LoginException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IOException(java.io.IOException) ProcessorException(org.talend.designer.runprocess.ProcessorException) BusinessException(org.talend.commons.exception.BusinessException) PersistenceException(org.talend.commons.exception.PersistenceException)

Aggregations

JobInfo (org.talend.core.model.process.JobInfo)3 JobResourceManager (org.talend.core.model.repository.job.JobResourceManager)3 ProcessorException (org.talend.designer.runprocess.ProcessorException)3 ArrayList (java.util.ArrayList)2 PersistenceException (org.talend.commons.exception.PersistenceException)2 ProcessItem (org.talend.core.model.properties.ProcessItem)2 JobResource (org.talend.core.model.repository.job.JobResource)2 ExportFileResource (org.talend.repository.documentation.ExportFileResource)2 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 CoreException (org.eclipse.core.runtime.CoreException)1 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)1 PartInitException (org.eclipse.ui.PartInitException)1 BusinessException (org.talend.commons.exception.BusinessException)1 LoginException (org.talend.commons.exception.LoginException)1 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)1 ArchiveFileExportOperationFullPath (org.talend.core.ui.export.ArchiveFileExportOperationFullPath)1 ExportChoice (org.talend.repository.ui.wizards.exportjob.scriptsmanager.JobScriptsManager.ExportChoice)1