Search in sources :

Example 6 with ILibrariesService

use of org.talend.core.model.general.ILibrariesService in project tdi-studio-se by Talend.

the class SubjobContainerPart method showModules.

private void showModules(Node node) {
    ILibrariesService moduleService = CorePlugin.getDefault().getLibrariesService();
    if (moduleService == null) {
        return;
    }
    List<Problem> problems = moduleService.getProblems(node, node);
    List<Problem> mproblems = new ArrayList<Problem>();
    List<String> modulesName = new ArrayList<String>();
    String componentName = null;
    String moduleStr = "Module_";
    for (Problem pro : problems) {
        if (pro.getStatus() == ProblemStatus.ERROR && pro.getKey() != null && pro.getKey().startsWith(moduleStr)) {
            mproblems.add(pro);
        }
    }
    if (mproblems.isEmpty()) {
        return;
    }
    for (Problem pro : mproblems) {
        if (componentName == null) {
            componentName = pro.getComponentName();
        }
        String key = pro.getKey();
        if (key.contains(moduleStr)) {
            int first = key.indexOf(moduleStr);
            String keydes = key.substring(first + moduleStr.length());
            modulesName.add(keydes);
        }
    }
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    final IWorkbenchPage page = window.getActivePage();
    if (page == null) {
        return;
    }
    try {
        IViewPart view = page.showView("org.talend.designer.codegen.perlmodule.ModulesView");
        if (view instanceof ModulesView) {
            ((ModulesView) view).selectUninstalledItem(componentName, modulesName);
        }
    } catch (PartInitException e) {
        ExceptionHandler.process(e);
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IViewPart(org.eclipse.ui.IViewPart) ModulesView(org.talend.librariesmanager.ui.views.ModulesView) ILibrariesService(org.talend.core.model.general.ILibrariesService) ArrayList(java.util.ArrayList) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) Problem(org.talend.core.model.process.Problem) PartInitException(org.eclipse.ui.PartInitException) Point(org.eclipse.draw2d.geometry.Point)

Example 7 with ILibrariesService

use of org.talend.core.model.general.ILibrariesService in project tesb-studio-se by Talend.

the class SyncNexusButtonController method deploy.

private void deploy(File file, String version) {
    try {
        if (GlobalServiceRegister.getDefault().isServiceRegistered(ILibrariesService.class)) {
            ILibrariesService service = (ILibrariesService) GlobalServiceRegister.getDefault().getService(ILibrariesService.class);
            service.deployLibrary(file.toURI().toURL(), version);
        }
    } catch (IOException ee) {
        ExceptionHandler.process(ee);
    }
}
Also used : ILibrariesService(org.talend.core.model.general.ILibrariesService) IOException(java.io.IOException)

Example 8 with ILibrariesService

use of org.talend.core.model.general.ILibrariesService in project tdi-studio-se by Talend.

the class ImportItemUtil method deployJarToDes.

@SuppressWarnings("unchecked")
private void deployJarToDes(final ResourcesManager manager, Set<String> extRoutines) {
    File file = null;
    if (extRoutines.isEmpty()) {
        return;
    }
    Set<URL> jarsToDeploy = new HashSet<URL>();
    for (Object element : manager.getPaths()) {
        String value = element.toString();
        file = new File(value);
        if (extRoutines.contains(file.getName())) {
            try {
                jarsToDeploy.add(file.toURL());
            } catch (MalformedURLException e) {
                ExceptionHandler.process(e);
            }
        }
    }
    if (jarsToDeploy.size() > 0) {
        ILibrariesService libService = (ILibrariesService) GlobalServiceRegister.getDefault().getService(ILibrariesService.class);
        try {
            libService.deployLibrarys(jarsToDeploy.toArray(new URL[0]));
        } catch (IOException e) {
            ExceptionHandler.process(e);
        }
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) ILibrariesService(org.talend.core.model.general.ILibrariesService) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RepositoryViewObject(org.talend.core.model.repository.RepositoryViewObject) InternalEObject(org.eclipse.emf.ecore.InternalEObject) EObject(org.eclipse.emf.ecore.EObject) IOException(java.io.IOException) File(java.io.File) URL(java.net.URL) HashSet(java.util.HashSet)

Example 9 with ILibrariesService

use of org.talend.core.model.general.ILibrariesService in project tesb-studio-se by Talend.

the class CamelTalendEditor method doSave.

@Override
public void doSave(IProgressMonitor monitor) {
    super.doSave(monitor);
    if (!PluginChecker.isTIS()) {
        return;
    }
    NexusServerBean nexusServerBean = TalendLibsServerManager.getInstance().getCustomNexusServer();
    if (nexusServerBean == null) {
        return;
    }
    if (GlobalServiceRegister.getDefault().isServiceRegistered(ILibrariesService.class)) {
        ILibrariesService service = (ILibrariesService) GlobalServiceRegister.getDefault().getService(ILibrariesService.class);
        List<? extends INode> graphicalNodes = this.getProcess().getGraphicalNodes();
        for (INode node : graphicalNodes) {
            if (node.getComponent().getName().equals("cConfig")) {
                List<Map<String, String>> jars = (List) node.getElementParameter("DRIVER_JAR").getValue();
                for (Map<String, String> o : jars) {
                    String jn = TalendQuoteUtils.removeQuotes(o.get("JAR_NAME"));
                    String jnv = TalendQuoteUtils.removeQuotes(o.get("JAR_NEXUS_VERSION"));
                    String jv = String.valueOf(o.get("JAR_PATH"));
                    String a = jn.replaceFirst("[.][^.]+$", "");
                    if (StringUtils.isNotBlank(jv)) {
                        File jarFile = new File(jv);
                        if (jarFile.exists()) {
                            try {
                                service.deployLibrary(jarFile.toURI().toURL(), "mvn:org.talend.libraries/" + a + "/" + jnv + "/jar");
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                            cConfigStoredInfo.put(jn, jnv);
                            o.put("JAR_PATH", "");
                        }
                    }
                    if (cConfigStoredInfo.get(jn) == null) {
                        cConfigStoredInfo.put(jn, jnv);
                        continue;
                    }
                    if (cConfigStoredInfo.get(jn).equals(jnv)) {
                        continue;
                    } else {
                        MavenArtifact ma = new MavenArtifact();
                        ma.setArtifactId(a);
                        ma.setGroupId("org.talend.libraries");
                        ma.setVersion(cConfigStoredInfo.get(jn));
                        ma.setType("jar");
                        String p = PomUtil.getAbsArtifactPath(ma);
                        if (p != null) {
                            File file = new File(p);
                            try {
                                if (file.exists()) {
                                    File tmp = new File(ExportJobUtil.getTmpFolder() + File.separator + jn);
                                    FilesUtils.copyFile(file, tmp);
                                    service.deployLibrary(tmp.toURI().toURL(), "mvn:org.talend.libraries/" + a + "/" + jnv + "/jar");
                                }
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : INode(org.talend.core.model.process.INode) ILibrariesService(org.talend.core.model.general.ILibrariesService) NexusServerBean(org.talend.core.nexus.NexusServerBean) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) File(java.io.File) MavenArtifact(org.talend.core.runtime.maven.MavenArtifact)

Aggregations

ILibrariesService (org.talend.core.model.general.ILibrariesService)9 File (java.io.File)5 IOException (java.io.IOException)5 URL (java.net.URL)3 InputStream (java.io.InputStream)2 MalformedURLException (java.net.MalformedURLException)2 HashSet (java.util.HashSet)2 List (java.util.List)2 Map (java.util.Map)2 Point (org.eclipse.draw2d.geometry.Point)2 INode (org.talend.core.model.process.INode)2 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)2 BufferedOutputStream (java.io.BufferedOutputStream)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 FileOutputStream (java.io.FileOutputStream)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 IFile (org.eclipse.core.resources.IFile)1 CoreException (org.eclipse.core.runtime.CoreException)1 IPath (org.eclipse.core.runtime.IPath)1