Search in sources :

Example 71 with IProcess

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

the class SpagicJavaDeployManager method getProperties.

public List<URL> getProperties(ProcessItem processItem, String contextName) {
    List<URL> list = new ArrayList<URL>();
    Properties p = new Properties();
    FileOutputStream out = null;
    String projectName = getCorrespondingProjectName(processItem);
    String jobName = processItem.getProperty().getLabel();
    String jobFolderName = JavaResourcesHelper.getJobFolderName(escapeFileNameSpace(processItem), processItem.getProperty().getVersion());
    try {
        // List<SpagoBiServer> listServerSapgo = null;
        // listServerSapgo = SpagicServerHelper.parse(new SpagicPreferencePage().getPreferenceStore().getString(
        // SpagoBiServer.SPAGOBI_SERVER));
        // if (listServerSapgo != null && !listServerSapgo.isEmpty()) {
        // Iterator<SpagoBiServer> iterator = listServerSapgo.iterator();
        // while (iterator.hasNext()) {
        // SpagoBiServer spagoBiServer = iterator.next();
        // }
        // }
        IPath path = getSrcRootLocation();
        //$NON-NLS-1$
        File file = new File(getTmpFolder() + PATH_SEPARATOR + "spagic.properties");
        //$NON-NLS-1$
        path = path.append(projectName).append(jobFolderName).append(jobName + ".java");
        BufferedReader buff = new BufferedReader(new FileReader(path.toPortableString()));
        int nbLine = 0;
        while (buff.readLine() != null) {
            nbLine++;
        }
        out = new FileOutputStream(file);
        PrintStream ps = new PrintStream(out);
        IDesignerCoreService service = CorePlugin.getDefault().getDesignerCoreService();
        IProcess process = service.getProcessFromProcessItem(processItem);
        List<IContextParameter> ctxParams = process.getContextManager().getContext(contextName).getContextParameterList();
        for (IContextParameter ctxParam : ctxParams) {
            p.put(ctxParam.getName(), ctxParam.getValue());
        }
        p.put("JobClassName", //$NON-NLS-1$
        getCorrespondingProjectName(null) + //$NON-NLS-1$
        "." + JavaResourcesHelper.getJobFolderName(processItem.getProperty().getLabel(), processItem.getProperty().getVersion()) + "." + //$NON-NLS-1$
        processItem.getProperty().getLabel());
        //$NON-NLS-1$
        p.put("talendJobClassDescription", HTMLDocUtils.checkString(processItem.getProperty().getDescription()));
        //$NON-NLS-1$
        p.put("rowNumber", Integer.toString(nbLine));
        //$NON-NLS-1$ //$NON-NLS-2$
        p.put("host", "localhost");
        p.list(ps);
        ps.flush();
        list.add(file.toURI().toURL());
    } catch (Exception e) {
        ExceptionHandler.process(e);
    } finally {
        if (out != null) {
            try {
                out.close();
            } catch (Exception e) {
            }
        }
    }
    return list;
}
Also used : PrintStream(java.io.PrintStream) IPath(org.eclipse.core.runtime.IPath) ArrayList(java.util.ArrayList) Properties(java.util.Properties) IContextParameter(org.talend.core.model.process.IContextParameter) URL(java.net.URL) ProcessorException(org.talend.designer.runprocess.ProcessorException) FileOutputStream(java.io.FileOutputStream) BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader) IDesignerCoreService(org.talend.designer.core.IDesignerCoreService) File(java.io.File) IProcess(org.talend.core.model.process.IProcess)

Example 72 with IProcess

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

the class MapperUI method openNewOutputCreationDialog.

public String openNewOutputCreationDialog() {
    final IProcess process = mapperManager.getMapperComponent().getProcess();
    //$NON-NLS-1$
    String outputName = process.generateUniqueConnectionName("out");
    InputDialog id = new InputDialog(mapperShell, "Add a output", "New Output :", outputName, new IInputValidator() {

        @Override
        public String isValid(String newText) {
            if (!process.checkValidConnectionName(newText)) {
                return "Output is invalid.";
            }
            return null;
        }
    });
    int response = id.open();
    if (response == InputDialog.OK) {
        return id.getValue();
    }
    return null;
}
Also used : InputDialog(org.eclipse.jface.dialogs.InputDialog) IProcess(org.talend.core.model.process.IProcess) IInputValidator(org.eclipse.jface.dialogs.IInputValidator)

Example 73 with IProcess

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

the class JavaProcessUtil method getChildrenModules.

static List<ModuleNeeded> getChildrenModules(final INode node, Set<ProcessItem> searchItems, boolean forMR) {
    List<ModuleNeeded> modulesNeeded = new ArrayList<ModuleNeeded>();
    if (node.getComponent().getName().equals("tRunJob")) {
        //$NON-NLS-1$
        //$NON-NLS-1$
        IElementParameter processIdparam = node.getElementParameter("PROCESS_TYPE_PROCESS");
        IElementParameter processVersionParam = node.getElementParameter(EParameterName.PROCESS_TYPE_VERSION.getName());
        ProcessItem processItem = null;
        if (processVersionParam != null) {
            processItem = ItemCacheManager.getProcessItem((String) processIdparam.getValue(), (String) processVersionParam.getValue());
        } else {
            processItem = ItemCacheManager.getProcessItem((String) processIdparam.getValue());
        }
        //$NON-NLS-1$
        String context = (String) node.getElementParameter("PROCESS_TYPE_CONTEXT").getValue();
        if (processItem != null && !searchItems.contains(processItem)) {
            boolean seperated = //$NON-NLS-1$
            getBooleanParamValue(node, "USE_INDEPENDENT_PROCESS") || //$NON-NLS-1$
            getBooleanParamValue(node, "USE_DYNAMIC_JOB");
            if (!seperated) {
                // avoid dead loop of method call
                searchItems.add(processItem);
                JobInfo subJobInfo = new JobInfo(processItem, context);
                IDesignerCoreService service = CorePlugin.getDefault().getDesignerCoreService();
                IProcess child = service.getProcessFromItem(subJobInfo.getProcessItem());
                getNeededModules(child, true, searchItems, modulesNeeded, forMR);
            }
        }
    }
    return modulesNeeded;
}
Also used : ProcessItem(org.talend.core.model.properties.ProcessItem) JobInfo(org.talend.core.model.process.JobInfo) ArrayList(java.util.ArrayList) IElementParameter(org.talend.core.model.process.IElementParameter) IDesignerCoreService(org.talend.designer.core.IDesignerCoreService) ModuleNeeded(org.talend.core.model.general.ModuleNeeded) IProcess(org.talend.core.model.process.IProcess)

Example 74 with IProcess

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

the class ProcessConvertServiceImpl method getProcessFromItem.

@Override
public IProcess getProcessFromItem(Item item, boolean loadScreenshots) {
    if (ProcessItemImpl.class == item.getClass()) {
        Process process = null;
        process = new Process(item.getProperty());
        process.loadXmlFile(loadScreenshots);
        return process;
    }
    return null;
}
Also used : IProcess(org.talend.core.model.process.IProcess) Process(org.talend.designer.core.ui.editor.process.Process)

Example 75 with IProcess

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

the class DesignerCoreService method getCurrentProcess.

// ends.
/*
     * (non-Javadoc)
     * 
     * @see org.talend.designer.core.IDesignerCoreService#getCurrentProcess()
     */
@Override
public IProcess getCurrentProcess() {
    IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
    if (!(editor instanceof AbstractMultiPageTalendEditor)) {
        return null;
    }
    IProcess process = ((AbstractMultiPageTalendEditor) editor).getProcess();
    return process;
}
Also used : AbstractMultiPageTalendEditor(org.talend.designer.core.ui.AbstractMultiPageTalendEditor) IEditorPart(org.eclipse.ui.IEditorPart) IProcess(org.talend.core.model.process.IProcess)

Aggregations

IProcess (org.talend.core.model.process.IProcess)102 INode (org.talend.core.model.process.INode)33 ArrayList (java.util.ArrayList)28 IDesignerCoreService (org.talend.designer.core.IDesignerCoreService)24 IProcess2 (org.talend.core.model.process.IProcess2)22 ProcessItem (org.talend.core.model.properties.ProcessItem)21 Node (org.talend.designer.core.ui.editor.nodes.Node)20 List (java.util.List)17 Item (org.talend.core.model.properties.Item)16 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)16 IOException (java.io.IOException)15 PersistenceException (org.talend.commons.exception.PersistenceException)14 IElementParameter (org.talend.core.model.process.IElementParameter)14 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)13 IEditorPart (org.eclipse.ui.IEditorPart)11 ProcessorException (org.talend.designer.runprocess.ProcessorException)10 File (java.io.File)9 Element (org.talend.core.model.process.Element)9 IConnection (org.talend.core.model.process.IConnection)9 IContext (org.talend.core.model.process.IContext)9