Search in sources :

Example 21 with ProcessItem

use of org.talend.core.model.properties.ProcessItem in project tdi-studio-se by Talend.

the class JavaJobScriptsExportWSWizardPage method createExportTypeGroup.

protected void createExportTypeGroup(Composite parent) {
    // options group
    Group optionsGroup = new Group(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    optionsGroup.setLayout(layout);
    optionsGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL));
    //$NON-NLS-1$
    optionsGroup.setText(Messages.getString("JavaJobScriptsExportWSWizardPage.BuildType"));
    optionsGroup.setFont(parent.getFont());
    optionsGroup.setLayout(new GridLayout(1, true));
    Composite left = new Composite(optionsGroup, SWT.NONE);
    left.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, false));
    left.setLayout(new GridLayout(3, false));
    Label label = new Label(left, SWT.NONE);
    //$NON-NLS-1$
    label.setText(Messages.getString("JavaJobScriptsExportWSWizardPage.BuildLabel"));
    exportTypeCombo = new Combo(left, SWT.PUSH);
    GridData gd = new GridData();
    gd.horizontalSpan = 1;
    exportTypeCombo.setLayoutData(gd);
    for (JobExportType exportType : extractExportJobTypes()) {
        if (!Boolean.getBoolean("talend.export.job.2." + exportType.toString() + ".hide")) {
            //$NON-NLS-1$//$NON-NLS-2$
            exportTypeCombo.add(exportType.label);
        }
    }
    String label2 = getCurrentExportType1().label;
    // if the build type was set, try to select by default
    if (nodes != null && nodes.length == 1) {
        // deal with one node only.
        ProcessItem item = getProcessItem();
        final Object buildType = item.getProperty().getAdditionalProperties().get(TalendProcessArgumentConstant.ARG_BUILD_TYPE);
        if (buildType != null) {
            Map<JobExportType, String> map = BuildJobFactory.oldBuildTypeMap;
            for (JobExportType t : map.keySet()) {
                if (buildType.toString().equals(map.get(t))) {
                    // same build type
                    label2 = t.label;
                    break;
                }
            }
        }
    }
    exportTypeCombo.setText(label2);
    if (exportTypeFixed != null) {
        left.setVisible(false);
        optionsGroup.setVisible(false);
        exportTypeCombo.setText(exportTypeFixed.label);
    }
    chkButton = new Button(left, SWT.CHECK);
    //$NON-NLS-1$
    chkButton.setText(Messages.getString("JavaJobScriptsExportWSWizardPage.extractZipFile"));
    JobExportType comboType = JobExportType.getTypeFromString(exportTypeCombo.getText());
    if (comboType.equals(JobExportType.WSWAR) || comboType.equals(JobExportType.OSGI)) {
        chkButton.setVisible(false);
        zipOption = null;
    } else {
        chkButton.setVisible(true);
        zipOption = String.valueOf(chkButton.getSelection());
    }
    chkButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            chkButton.setSelection(chkButton.getSelection());
            zipOption = String.valueOf(chkButton.getSelection());
        }
    });
    exportTypeCombo.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            destinationNameFieldInnerComposite.dispose();
            destinationNameFieldInnerComposite = new Composite(destinationNameFieldComposite, SWT.NONE);
            GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL);
            destinationNameFieldInnerComposite.setLayoutData(gridData);
            destinationNameFieldInnerComposite.setLayout(new GridLayout());
            createDestinationGroup(destinationNameFieldInnerComposite);
            destinationNameFieldComposite.layout();
            optionsGroupComposite.dispose();
            createOptionsGroupButtons(pageComposite);
            pageComposite.setSize(pageComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
            pageComposite.layout();
            JobExportType comboType = JobExportType.getTypeFromString(exportTypeCombo.getText());
            if (comboType.equals(JobExportType.WSWAR) || comboType.equals(JobExportType.OSGI)) {
                chkButton.setVisible(false);
                zipOption = null;
            } else {
                chkButton.setVisible(true);
                zipOption = String.valueOf(chkButton.getSelection());
            }
            checkExport();
        }
    });
}
Also used : Group(org.eclipse.swt.widgets.Group) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) GridLayout(org.eclipse.swt.layout.GridLayout) ProcessItem(org.talend.core.model.properties.ProcessItem) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 22 with ProcessItem

use of org.talend.core.model.properties.ProcessItem in project tdi-studio-se by Talend.

the class BuildJobManager method buildJobs.

public boolean buildJobs(String destinationPath, List<? extends IRepositoryNode> nodes, List<String> topNames, String version, String context, Map<ExportChoice, Object> exportChoiceMap, JobExportType jobExportType, IProgressMonitor monitor) throws Exception {
    IProgressMonitor pMonitor = new NullProgressMonitor();
    if (monitor != null) {
        pMonitor = monitor;
    }
    final List<ProcessItem> processes = getProcesses(nodes);
    if (processes.size() == 1) {
        ProcessItem item = processes.get(0);
        buildJob(destinationPath, item, version, context, exportChoiceMap, jobExportType, pMonitor);
    } else {
        int scale = 1000;
        int steps = 3;
        pMonitor.beginTask(Messages.getString("JobScriptsExportWizardPage.newExportJobScript", jobExportType), //$NON-NLS-1$
        steps * scale * nodes.size());
        String topName = null;
        if (topNames != null && !topNames.isEmpty()) {
            topName = topNames.get(0);
        } else {
            topName = ProjectManager.getInstance().getCurrentProject().getLabel();
        }
        File desFile = new File(destinationPath);
        //$NON-NLS-1$ //$NON-NLS-2$
        File createTempFile = File.createTempFile("building_job", "");
        createTempFile.delete();
        File tempFolder = new File(desFile.getParent() + File.separator + createTempFile.getName());
        if (tempFolder.exists()) {
            tempFolder.delete();
        }
        File tempProFolder = new File(tempFolder, topName);
        tempProFolder.mkdirs();
        for (int i = 0; i < processes.size(); i++) {
            ProcessItem processItem = processes.get(i);
            //$NON-NLS-1$
            pMonitor.setTaskName(Messages.getString("BuildJobManager.building", processItem.getProperty().getLabel()));
            IBuildJobHandler buildJobHandler = BuildJobFactory.createBuildJobHandler(processItem, context, processItem.getProperty().getVersion(), exportChoiceMap, jobExportType);
            buildJobHandler.generateItemFiles(true, new SubProgressMonitor(pMonitor, scale));
            buildJobHandler.generateJobFiles(new SubProgressMonitor(pMonitor, scale));
            buildJobHandler.build(new SubProgressMonitor(pMonitor, scale));
            IFile jobTargetFile = buildJobHandler.getJobTargetFile();
            if (jobTargetFile != null && jobTargetFile.exists()) {
                // unzip to temp folder
                FilesUtils.unzip(jobTargetFile.getLocation().toPortableString(), tempProFolder.getAbsolutePath());
                String zipPath = jobTargetFile.getLocation().toPortableString();
                if (needClasspathJar(exportChoiceMap)) {
                    JavaJobExportReArchieveCreator creator = new JavaJobExportReArchieveCreator(zipPath, processItem.getProperty().getLabel());
                    creator.setTempFolder(tempFolder.getAbsolutePath());
                    creator.buildNewJar();
                }
            }
            pMonitor.worked(scale);
        }
        FilesUtils.zip(tempFolder.getAbsolutePath(), destinationPath);
        FilesUtils.deleteFile(tempFolder, true);
        pMonitor.done();
    }
    return true;
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IFile(org.eclipse.core.resources.IFile) ProcessItem(org.talend.core.model.properties.ProcessItem) IBuildJobHandler(org.talend.core.runtime.process.IBuildJobHandler) JavaJobExportReArchieveCreator(org.talend.repository.ui.wizards.exportjob.JavaJobExportReArchieveCreator) ZipToFile(org.talend.repository.ui.utils.ZipToFile) IFile(org.eclipse.core.resources.IFile) File(java.io.File) SubProgressMonitor(org.eclipse.core.runtime.SubProgressMonitor)

Example 23 with ProcessItem

use of org.talend.core.model.properties.ProcessItem in project tdi-studio-se by Talend.

the class JobJavaScriptsManager method collectRoutines.

protected Collection<IRepositoryViewObject> collectRoutines(ExportFileResource[] process, String type) {
    List<IRepositoryViewObject> toReturn = new ArrayList<IRepositoryViewObject>();
    if (USER_BEANS_PATH.equals(type)) {
        ERepositoryObjectType beansType = null;
        if (GlobalServiceRegister.getDefault().isServiceRegistered(ICamelDesignerCoreService.class)) {
            ICamelDesignerCoreService service = (ICamelDesignerCoreService) GlobalServiceRegister.getDefault().getService(ICamelDesignerCoreService.class);
            beansType = service.getBeansType();
        }
        try {
            toReturn = ProxyRepositoryFactory.getInstance().getAll(beansType);
        } catch (PersistenceException e) {
            ExceptionHandler.process(e);
            toReturn = Collections.emptyList();
        }
    } else {
        Set<String> allRoutinesNames = new HashSet<String>();
        ERepositoryObjectType objectType = ERepositoryObjectType.ROUTINES;
        if (USER_PIGUDF_PATH.equals(type)) {
            objectType = ERepositoryObjectType.PIG_UDF;
        }
        if (ERepositoryObjectType.ROUTINES == objectType) {
            for (ExportFileResource resource : process) {
                if (resource.getItem() instanceof ProcessItem) {
                    Set<String> routinesNeededForJob = LastGenerationInfo.getInstance().getRoutinesNeededWithSubjobPerJob(resource.getItem().getProperty().getId(), resource.getItem().getProperty().getVersion());
                    if (routinesNeededForJob != null) {
                        allRoutinesNames.addAll(routinesNeededForJob);
                    }
                }
            }
        } else {
            for (ExportFileResource resource : process) {
                if (resource.getItem() instanceof ProcessItem) {
                    Set<String> routinesNeededForJob = LastGenerationInfo.getInstance().getPigudfNeededWithSubjobPerJob(resource.getItem().getProperty().getId(), resource.getItem().getProperty().getVersion());
                    if (routinesNeededForJob != null) {
                        allRoutinesNames.addAll(routinesNeededForJob);
                    }
                }
            }
        }
        if (allRoutinesNames.isEmpty()) {
            toReturn.addAll(RoutinesUtil.getCurrentSystemRoutines());
        } else {
            toReturn.addAll(collectRoutinesFromRepository(allRoutinesNames, objectType));
        }
    }
    return toReturn;
}
Also used : ICamelDesignerCoreService(org.talend.designer.core.ICamelDesignerCoreService) ProcessItem(org.talend.core.model.properties.ProcessItem) ExportFileResource(org.talend.repository.documentation.ExportFileResource) ArrayList(java.util.ArrayList) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) LinkedHashSet(java.util.LinkedHashSet) HashSet(java.util.HashSet)

Example 24 with ProcessItem

use of org.talend.core.model.properties.ProcessItem in project tdi-studio-se by Talend.

the class AbstractStandardJobBuildProviderTest method createJobItem.

protected Item createJobItem() throws PersistenceException {
    final IProxyRepositoryFactory repositoryFactory = DesignerPlugin.getDefault().getRepositoryService().getProxyRepositoryFactory();
    final String testJobId = repositoryFactory.getNextId();
    final String testJobLabel = StandardJobStandaloneBuildProvider.class.getSimpleName() + System.currentTimeMillis();
    // copied from NewProcessWizard
    Property property = PropertiesFactory.eINSTANCE.createProperty();
    property.setAuthor(((RepositoryContext) CorePlugin.getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY)).getUser());
    property.setVersion(VersionUtils.DEFAULT_VERSION);
    property.setStatusCode("");
    property.setId(testJobId);
    property.setDisplayName(testJobLabel);
    property.setLabel(property.getDisplayName());
    ProcessItem processItem = PropertiesFactory.eINSTANCE.createProcessItem();
    processItem.setProperty(property);
    property.setItem(processItem);
    ProcessType process = TalendFileFactory.eINSTANCE.createProcessType();
    ParametersType parameterType = TalendFileFactory.eINSTANCE.createParametersType();
    List<RoutinesParameterType> dependenciesInPreference = RoutinesUtil.createDependenciesInPreference();
    parameterType.getRoutinesParameter().addAll(dependenciesInPreference);
    process.setParameters(parameterType);
    processItem.setProcess(process);
    repositoryFactory.create(processItem, new Path(""));
    return processItem;
}
Also used : Path(org.eclipse.core.runtime.Path) ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) ProcessItem(org.talend.core.model.properties.ProcessItem) RoutinesParameterType(org.talend.designer.core.model.utils.emf.talendfile.RoutinesParameterType) ParametersType(org.talend.designer.core.model.utils.emf.talendfile.ParametersType) Property(org.talend.core.model.properties.Property) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 25 with ProcessItem

use of org.talend.core.model.properties.ProcessItem in project tdi-studio-se by Talend.

the class BuildJobHandlerTest method setUp.

@Before
public void setUp() throws Exception {
    // Fix the NPE for org.talend.designer.core.ui.editor.process.Process.createMainParameters(Process.java:401)
    bridgeProject = ReponsitoryContextBridge.getProject();
    ReponsitoryContextBridge.setProject(ProjectManager.getInstance().getCurrentProject().getEmfProject());
    ImportExportHandlersManager importManager = new ImportExportHandlersManager();
    // job with tdm and tdq component.
    URL testJobURL = FileLocator.find(Platform.getBundle("org.talend.repository.test"), new Path("/resources/testBuildJob.zip"), null);
    if (testJobURL != null) {
        testJobURL = FileLocator.toFileURL(testJobURL);
    }
    File srcFile = new File(testJobURL.getFile());
    FileResourcesUnityManager fileUnityManager = ResourcesManagerFactory.getInstance().createFileUnityManager(srcFile);
    ResourcesManager resManager = fileUnityManager.doUnify();
    List<ImportItem> projectRecords = importManager.populateImportingItems(resManager, true, new NullProgressMonitor());
    assertTrue(projectRecords.size() > 0);
    importManager.importItemRecords(new NullProgressMonitor(), resManager, projectRecords, true, projectRecords.toArray(new ImportItem[0]), null);
    IRepositoryViewObject obj = ProxyRepositoryFactory.getInstance().getLastVersion("_bWyBUAYbEeapTZ0aKwL_YA");
    Item item = obj.getProperty().getItem();
    assertTrue(item instanceof ProcessItem);
    processItem = (ProcessItem) item;
}
Also used : ImportExportHandlersManager(org.talend.repository.items.importexport.handlers.ImportExportHandlersManager) Path(org.eclipse.core.runtime.Path) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ImportItem(org.talend.repository.items.importexport.handlers.model.ImportItem) ProcessItem(org.talend.core.model.properties.ProcessItem) Item(org.talend.core.model.properties.Item) ImportItem(org.talend.repository.items.importexport.handlers.model.ImportItem) ProcessItem(org.talend.core.model.properties.ProcessItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) FileResourcesUnityManager(org.talend.repository.items.importexport.ui.managers.FileResourcesUnityManager) ResourcesManager(org.talend.repository.items.importexport.manager.ResourcesManager) ZipFile(java.util.zip.ZipFile) File(java.io.File) URL(java.net.URL) Before(org.junit.Before)

Aggregations

ProcessItem (org.talend.core.model.properties.ProcessItem)191 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)58 PersistenceException (org.talend.commons.exception.PersistenceException)56 ArrayList (java.util.ArrayList)45 Item (org.talend.core.model.properties.Item)43 Property (org.talend.core.model.properties.Property)43 JobletProcessItem (org.talend.core.model.properties.JobletProcessItem)37 ProcessType (org.talend.designer.core.model.utils.emf.talendfile.ProcessType)29 IProcess2 (org.talend.core.model.process.IProcess2)25 NodeType (org.talend.designer.core.model.utils.emf.talendfile.NodeType)25 IProcess (org.talend.core.model.process.IProcess)24 ExportFileResource (org.talend.repository.documentation.ExportFileResource)24 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)24 File (java.io.File)23 INode (org.talend.core.model.process.INode)23 IDesignerCoreService (org.talend.designer.core.IDesignerCoreService)22 IOException (java.io.IOException)21 IFile (org.eclipse.core.resources.IFile)20 List (java.util.List)19 EList (org.eclipse.emf.common.util.EList)19