Search in sources :

Example 76 with IProcess2

use of org.talend.core.model.process.IProcess2 in project tdi-studio-se by Talend.

the class MultiPageTalendEditor method setName.

/**
     * DOC smallet Comment method "setName".
     * 
     * @param label
     */
@Override
public void setName() {
    if (getEditorInput() == null) {
        return;
    }
    super.setName();
    IProcess2 process2 = this.getProcess();
    if (process2 == null) {
        return;
    }
    Property property = process2.getProperty();
    if (property == null) {
        return;
    }
    String label = property.getDisplayName();
    //$NON-NLS-1$
    String jobVersion = "0.1";
    if (process2 != null) {
        jobVersion = process2.getVersion();
    }
    // if (getActivePage() == 1) {
    ISVNProviderService service = null;
    if (PluginChecker.isSVNProviderPluginLoaded()) {
        service = (ISVNProviderService) GlobalServiceRegister.getDefault().getService(ISVNProviderService.class);
        if (revisionChanged && service.isProjectInSvnMode()) {
            revisionNumStr = service.getCurrentSVNRevision(process2);
            revisionChanged = false;
            if (revisionNumStr != null) {
                //$NON-NLS-1$
                revisionNumStr = ".r" + revisionNumStr;
            }
        }
    }
    //$NON-NLS-1$
    String title = "MultiPageTalendEditor.Job";
    if (process2 != null) {
        Item item = process2.getProperty().getItem();
        if (item instanceof JobletProcessItem) {
            //$NON-NLS-1$
            title = "MultiPageTalendEditor.Joblet";
        }
    }
    IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
    boolean allowVerchange = brandingService.getBrandingConfiguration().isAllowChengeVersion();
    if (allowVerchange) {
        if (revisionNumStr != null) {
            setPartName(Messages.getString(title, label, jobVersion) + revisionNumStr);
        } else {
            setPartName(Messages.getString(title, label, jobVersion));
        }
    } else {
        if (revisionNumStr != null) {
            //$NON-NLS-1$
            setPartName(Messages.getString(title, label, "") + revisionNumStr);
        } else {
            //$NON-NLS-1$
            setPartName(Messages.getString(title, label, ""));
        }
    }
}
Also used : Item(org.talend.core.model.properties.Item) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) IProcess2(org.talend.core.model.process.IProcess2) ISVNProviderService(org.talend.core.services.ISVNProviderService) IBrandingService(org.talend.core.ui.branding.IBrandingService) Property(org.talend.core.model.properties.Property)

Example 77 with IProcess2

use of org.talend.core.model.process.IProcess2 in project tdi-studio-se by Talend.

the class AbstractMultiPageTalendEditor method refreshProcess.

/**
     * Refresh the editor/process to the given refreshedItem version
     * 
     * @param refreshedItem
     * @param force
     */
private void refreshProcess(final Item refreshedItem, boolean force) {
    Item currentItem = processEditorInput.getItem();
    if (isStorageVersionChanged(refreshedItem, currentItem) || force) {
        processEditorInput.setItem(refreshedItem);
        final IProcess2 process = processEditorInput.getLoadedProcess();
        getSite().getShell().getDisplay().syncExec(new Runnable() {

            @Override
            public void run() {
                process.setProperty(refreshedItem.getProperty());
                process.updateProperties();
                ProcessType processType = null;
                if (refreshedItem instanceof ProcessItem) {
                    processType = ((ProcessItem) refreshedItem).getProcess();
                } else if (refreshedItem instanceof JobletProcessItem) {
                    processType = ((JobletProcessItem) refreshedItem).getJobletProcess();
                } else {
                    //$NON-NLS-1$
                    ExceptionHandler.process(new Exception("Mismatched case"));
                }
                if (processType != null) {
                    ((Process) process).updateProcess(processType);
                }
                process.refreshProcess();
                revisionChanged = true;
                setName();
            }
        });
    }
}
Also used : JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) ProcessItem(org.talend.core.model.properties.ProcessItem) Item(org.talend.core.model.properties.Item) ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) ProcessItem(org.talend.core.model.properties.ProcessItem) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) IProcess2(org.talend.core.model.process.IProcess2) 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)

Example 78 with IProcess2

use of org.talend.core.model.process.IProcess2 in project tdi-studio-se by Talend.

the class AbstractMultiPageTalendEditor method createPage1.

/**
     * Creates page 1 of the multi-page editor, which allows you to change the font used in page 2.
     */
protected void createPage1() {
    IProcess2 process = getProcess();
    codeEditor = CodeEditorFactory.getInstance().getCodeEditor(getCurrentLang(), process);
    processor = ProcessorUtilities.getProcessor(process, process.getProperty(), process.getContextManager().getDefaultContext());
    if (processor instanceof IJavaBreakpointListener) {
        JDIDebugModel.addJavaBreakpointListener((IJavaBreakpointListener) processor);
    }
    processor.setProcessorStates(IProcessor.STATES_EDIT);
    if (codeEditor instanceof ISyntaxCheckableEditor) {
        processor.setSyntaxCheckableEditor((ISyntaxCheckableEditor) codeEditor);
    }
    if (useCodeView) {
        try {
            IEditorInput editorInput = createFileEditorInput();
            if (!(process.getProperty().getItem() instanceof ProcessItem)) {
                // shouldn't work for joblet
                editorInput = new JobletCodeEditInput();
            }
            int index = addPage(codeEditor, editorInput);
            // init Syntax Validation.
            //$NON-NLS-1$
            setPageText(index, "Code");
        } catch (PartInitException pie) {
            // pie.printStackTrace();
            ExceptionHandler.process(pie);
        }
    }
    if (DesignerPlugin.getDefault().getPreferenceStore().getBoolean(TalendDesignerPrefConstants.GENERATE_CODE_WHEN_OPEN_JOB)) {
        generateCode();
    }
}
Also used : ISyntaxCheckableEditor(org.talend.designer.core.ISyntaxCheckableEditor) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) ProcessItem(org.talend.core.model.properties.ProcessItem) IProcess2(org.talend.core.model.process.IProcess2) PartInitException(org.eclipse.ui.PartInitException) IJavaBreakpointListener(org.eclipse.jdt.debug.core.IJavaBreakpointListener) IEditorInput(org.eclipse.ui.IEditorInput) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint)

Example 79 with IProcess2

use of org.talend.core.model.process.IProcess2 in project tdi-studio-se by Talend.

the class ElementParameter2ParameterType method loadProjectsettingsParameters.

/**
     * DOC zli Comment method "loadProjectsettingsParameters".
     *
     * @param parameters
     */
public static void loadProjectsettingsParameters(ParametersType parameters) {
    IEditorReference[] reference = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences();
    IDesignerCoreService designerCoreService = CorePlugin.getDefault().getDesignerCoreService();
    designerCoreService.switchToCurJobSettingsView();
    List<IProcess2> openedProcess = designerCoreService.getOpenedProcess(reference);
    for (IProcess2 process : openedProcess) {
        if (process instanceof Element) {
            Element processElem = (Element) process;
            ElementParameter2ParameterType.loadElementParameters(processElem, parameters, null);
        }
        process.setNeedRegenerateCode(true);
    }
    IProxyRepositoryFactory repositoryFactory = CorePlugin.getDefault().getProxyRepositoryFactory();
    IProcess process = null;
    try {
        List<IRepositoryViewObject> all = repositoryFactory.getAll(ERepositoryObjectType.PROCESS);
        for (IRepositoryViewObject object : all) {
            if (!openedProcess.contains(object)) {
                Item item = object.getProperty().getItem();
                if (item instanceof ProcessItem) {
                    process = designerCoreService.getProcessFromProcessItem((ProcessItem) item);
                    if (process != null && process instanceof IProcess2) {
                        IProcess2 process2 = (IProcess2) process;
                        if (process2 instanceof Element) {
                            Element processElem = (Element) process2;
                            ElementParameter2ParameterType.loadElementParameters(processElem, parameters, null);
                            ProcessType processType = process2.saveXmlFile();
                            if (processType != null) {
                                ((ProcessItem) item).setProcess(processType);
                            }
                            repositoryFactory.save(item);
                        }
                    }
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : Element(org.talend.core.model.process.Element) ProcessItem(org.talend.core.model.properties.ProcessItem) Item(org.talend.core.model.properties.Item) ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) IEditorReference(org.eclipse.ui.IEditorReference) ProcessItem(org.talend.core.model.properties.ProcessItem) IProcess2(org.talend.core.model.process.IProcess2) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IDesignerCoreService(org.talend.designer.core.IDesignerCoreService) IProcess(org.talend.core.model.process.IProcess) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 80 with IProcess2

use of org.talend.core.model.process.IProcess2 in project tdi-studio-se by Talend.

the class BigDataJavaProcessor method extractArgumentSegments.

@Override
public List<String> extractArgumentSegments() {
    List<String> list = new ArrayList<>();
    list.add(ProcessorConstants.CMD_KEY_WORD_LIBJAR);
    StringBuffer libJars = new StringBuffer();
    Set<String> libNames = null;
    boolean isExport = isExportConfig() || isRunAsExport();
    if (process instanceof IProcess2) {
        if (isExport) {
            // In an export mode, all the dependencies and the routines/beans/udfs are packaged in the lib folder.
            libNames = JavaProcessorUtilities.extractLibNamesOnlyForMapperAndReducer((IProcess2) process);
        } else {
            // In the local mode, all the dependencies are packaged in the lib folder. The routines/beans/udfs are
            // not.
            // We will
            // handle them separetely.
            libNames = JavaProcessorUtilities.extractLibNamesOnlyForMapperAndReducerWithoutRoutines((IProcess2) process);
        }
    }
    File libDir = JavaProcessorUtilities.getJavaProjectLibFolder();
    File targetDir = new File(JavaProcessorUtilities.getTalendJavaProject().getTargetFolder().getLocationURI());
    //$NON-NLS-1$
    String libFolder = "";
    if (libDir != null) {
        libFolder = new Path(libDir.getAbsolutePath()).toPortableString();
    }
    // StringBuffer.
    if (libNames != null && libNames.size() > 0) {
        Iterator<String> itLibNames = libNames.iterator();
        while (itLibNames.hasNext()) {
            if (isExport) {
                // In an export mode, the path is relative to the working directory.
                libJars.append(getLibFolderInWorkingDir() + itLibNames.next()).append(',');
            } else {
                // In a local mode, the path is absolute.
                //$NON-NLS-1$
                libJars.append(libFolder + "/" + itLibNames.next()).append(',');
            }
        }
    }
    if (isExport) {
        // In an export mode, we add the job jar which is located in the current working directory
        //$NON-NLS-1$
        libJars.append("./" + makeupJobJarName());
    } else {
        // In a local mode,we must append the routines/beans/udfs jars which are located in the target directory.
        Set<FilterInfo> codeJars = new HashSet<>();
        codeJars.add(new FilterInfo(JavaUtils.ROUTINE_JAR_NAME, FileExtensions.JAR_FILE_SUFFIX));
        codeJars.add(new FilterInfo(JavaUtils.BEANS_JAR_NAME, FileExtensions.JAR_FILE_SUFFIX));
        codeJars.add(new FilterInfo(JavaUtils.PIGUDFS_JAR_NAME, FileExtensions.JAR_FILE_SUFFIX));
        List<File> files = FileUtils.getAllFilesFromFolder(targetDir, codeJars);
        boolean routinesHaveBeenFound = false;
        for (File f : files) {
            if (!routinesHaveBeenFound && f.getName().startsWith(JavaUtils.ROUTINE_JAR_NAME)) {
                routinesHaveBeenFound = true;
            }
            //$NON-NLS-1$
            libJars.append(new Path(f.getAbsolutePath()).toPortableString() + ",");
        }
        // folder when the job is going to be running.
        if (!routinesHaveBeenFound) {
            File routinesJar = new File(//$NON-NLS-1$ //$NON-NLS-2$
            targetDir + "/" + JavaUtils.ROUTINE_JAR_NAME + "-" + PomUtil.getDefaultMavenVersion() + FileExtensions.JAR_FILE_SUFFIX);
            //$NON-NLS-1$
            libJars.append(new Path(routinesJar.getAbsolutePath()).toPortableString() + ",");
        }
        // ... and add the jar of the job itself also located in the target directory/
        if (targetDir != null) {
            //$NON-NLS-1$
            libJars.append(new Path(targetDir.getAbsolutePath()).toPortableString() + "/" + makeupJobJarName());
        }
    }
    list.add(libJars.toString());
    return list;
}
Also used : Path(org.eclipse.core.runtime.Path) ArrayList(java.util.ArrayList) IProcess2(org.talend.core.model.process.IProcess2) File(java.io.File) FilterInfo(org.talend.utils.files.FilterInfo) HashSet(java.util.HashSet)

Aggregations

IProcess2 (org.talend.core.model.process.IProcess2)115 INode (org.talend.core.model.process.INode)31 Node (org.talend.designer.core.ui.editor.nodes.Node)31 ArrayList (java.util.ArrayList)30 ProcessItem (org.talend.core.model.properties.ProcessItem)30 Item (org.talend.core.model.properties.Item)28 IProcess (org.talend.core.model.process.IProcess)24 PersistenceException (org.talend.commons.exception.PersistenceException)22 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)21 JobletProcessItem (org.talend.core.model.properties.JobletProcessItem)19 List (java.util.List)17 IElementParameter (org.talend.core.model.process.IElementParameter)15 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)14 Property (org.talend.core.model.properties.Property)14 CoreException (org.eclipse.core.runtime.CoreException)12 IConnection (org.talend.core.model.process.IConnection)11 HashSet (java.util.HashSet)10 IEditorReference (org.eclipse.ui.IEditorReference)10 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)10 InvocationTargetException (java.lang.reflect.InvocationTargetException)7