Search in sources :

Example 26 with IDesignerCoreService

use of org.talend.designer.core.IDesignerCoreService in project tdi-studio-se by Talend.

the class DataSourceConfig method getSubProcessNodesFromTRunjob.

private static List<? extends INode> getSubProcessNodesFromTRunjob(INode tRunJobNode) {
    //$NON-NLS-1$
    String processId = (String) tRunJobNode.getElementParameter("PROCESS:PROCESS_TYPE_PROCESS").getValue();
    if (processId != null && !"".equals(processId)) {
        //$NON-NLS-1$
        ProcessItem processItem = ItemCacheManager.getProcessItem(processId);
        IDesignerCoreService service = CorePlugin.getDefault().getDesignerCoreService();
        if (processItem != null && service != null) {
            return service.getProcessFromItem(processItem).getGeneratingNodes();
        }
    }
    return null;
}
Also used : ProcessItem(org.talend.core.model.properties.ProcessItem) IDesignerCoreService(org.talend.designer.core.IDesignerCoreService)

Example 27 with IDesignerCoreService

use of org.talend.designer.core.IDesignerCoreService in project tesb-studio-se by Talend.

the class AssignJobAction method changeOldJob.

public void changeOldJob() {
    String operationName = repositoryNode.getObject().getLabel();
    String portName = repositoryNode.getParent().getObject().getLabel();
    ServiceItem serviceItem = (ServiceItem) repositoryNode.getParent().getParent().getObject().getProperty().getItem();
    List<ServicePort> listPort = ((ServiceConnection) serviceItem.getConnection()).getServicePort();
    String oldJobID = null;
    for (ServicePort port : listPort) {
        if (port.getName().equals(portName)) {
            List<ServiceOperation> listOperation = port.getServiceOperation();
            for (ServiceOperation operation : listOperation) {
                if (operation.getLabel().equals(operationName)) {
                    oldJobID = operation.getReferenceJobId();
                    break;
                }
            }
            break;
        }
    }
    IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
    try {
        if (oldJobID != null) {
            IRepositoryViewObject object = factory.getLastVersion(oldJobID);
            Item item = object.getProperty().getItem();
            ProcessItem processItem = (ProcessItem) item;
            //
            IDesignerCoreService service = CorePlugin.getDefault().getDesignerCoreService();
            IProcess2 process = null;
            IEditorReference[] reference = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences();
            List<IProcess2> processes = RepositoryPlugin.getDefault().getDesignerCoreService().getOpenedProcess(reference);
            for (IProcess2 processOpen : processes) {
                if (processOpen.getProperty().getItem() == processItem) {
                    process = processOpen;
                    break;
                }
            }
            if (process == null) {
                IProcess proc = service.getProcessFromProcessItem(processItem);
                if (proc instanceof IProcess2) {
                    process = (IProcess2) proc;
                }
            }
            if (process != null) {
                List<? extends INode> nodelist = process.getGraphicalNodes();
                for (INode node : nodelist) {
                    if (node.getComponent().getName().equals("tESBProviderRequest")) {
                        repositoryChangeToBuildIn(repositoryNode, node);
                    }
                }
                processItem.setProcess(process.saveXmlFile());
                factory.save(processItem);
            }
        }
    } catch (PersistenceException | IOException e) {
        ExceptionHandler.process(e);
    }
}
Also used : ServicePort(org.talend.repository.services.model.services.ServicePort) ServiceConnection(org.talend.repository.services.model.services.ServiceConnection) INode(org.talend.core.model.process.INode) ServiceOperation(org.talend.repository.services.model.services.ServiceOperation) IOException(java.io.IOException) Item(org.talend.core.model.properties.Item) ConnectionItem(org.talend.core.model.properties.ConnectionItem) ServiceItem(org.talend.repository.services.model.services.ServiceItem) ProcessItem(org.talend.core.model.properties.ProcessItem) IEditorReference(org.eclipse.ui.IEditorReference) ProcessItem(org.talend.core.model.properties.ProcessItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IProcess2(org.talend.core.model.process.IProcess2) PersistenceException(org.talend.commons.exception.PersistenceException) ServiceItem(org.talend.repository.services.model.services.ServiceItem) IDesignerCoreService(org.talend.designer.core.IDesignerCoreService) IProcess(org.talend.core.model.process.IProcess) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 28 with IDesignerCoreService

use of org.talend.designer.core.IDesignerCoreService 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 29 with IDesignerCoreService

use of org.talend.designer.core.IDesignerCoreService in project tdi-studio-se by Talend.

the class VisibleComponentSettingsMigrationTask method execute.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.core.model.migration.AbstractItemMigrationTask#execute(org.talend.core.model.properties.Item)
     */
@Override
public ExecutionResult execute(Item item) {
    ProcessType processType = getProcessType(item);
    IDesignerCoreService designerCoreService = CorePlugin.getDefault().getDesignerCoreService();
    Project currentProject = ProjectManager.getInstance().getCurrentProject();
    List<ComponentSetting> componentsSettings = (List<ComponentSetting>) currentProject.getEmfProject().getComponentsSettings();
    boolean modified = false;
    if (processType != null) {
        EList nodes = processType.getNode();
        for (Object node : nodes) {
            NodeType nodeType = (NodeType) node;
            for (ComponentSetting setting : componentsSettings) {
                if (setting.getName().equals(nodeType.getComponentName())) {
                    if (setting.isHidden()) {
                        setting.setHidden(false);
                        modified = true;
                    }
                }
            }
        }
    }
    if (modified) {
        IProxyRepositoryFactory prf = CorePlugin.getDefault().getProxyRepositoryFactory();
        try {
            prf.saveProject(currentProject);
        } catch (Exception ex) {
            ExceptionHandler.process(ex);
            return ExecutionResult.FAILURE;
        }
        return ExecutionResult.SUCCESS_NO_ALERT;
    }
    return ExecutionResult.NOTHING_TO_DO;
}
Also used : Project(org.talend.core.model.general.Project) ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) EList(org.eclipse.emf.common.util.EList) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) EList(org.eclipse.emf.common.util.EList) List(java.util.List) IDesignerCoreService(org.talend.designer.core.IDesignerCoreService) ComponentSetting(org.talend.core.model.properties.ComponentSetting) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 30 with IDesignerCoreService

use of org.talend.designer.core.IDesignerCoreService 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)

Aggregations

IDesignerCoreService (org.talend.designer.core.IDesignerCoreService)40 IProcess (org.talend.core.model.process.IProcess)25 ProcessItem (org.talend.core.model.properties.ProcessItem)21 Item (org.talend.core.model.properties.Item)13 ArrayList (java.util.ArrayList)12 INode (org.talend.core.model.process.INode)12 PersistenceException (org.talend.commons.exception.PersistenceException)10 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)9 IOException (java.io.IOException)8 List (java.util.List)8 IProcess2 (org.talend.core.model.process.IProcess2)7 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)7 IFile (org.eclipse.core.resources.IFile)6 IElementParameter (org.talend.core.model.process.IElementParameter)6 Process (org.talend.designer.core.ui.editor.process.Process)6 HashMap (java.util.HashMap)5 HashSet (java.util.HashSet)5 IEditorReference (org.eclipse.ui.IEditorReference)5 ProcessType (org.talend.designer.core.model.utils.emf.talendfile.ProcessType)5 File (java.io.File)4