Search in sources :

Example 11 with ICamelDesignerCoreService

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

the class JobJavaScriptsManager method getUserRoutine.

/**
     * Gets user routine.
     * 
     * @param needUserRoutine
     * @return
     */
protected List<URL> getUserRoutine(ExportFileResource[] process) {
    try {
        boolean useBeans = false;
        if (GlobalServiceRegister.getDefault().isServiceRegistered(ICamelDesignerCoreService.class)) {
            ICamelDesignerCoreService service = (ICamelDesignerCoreService) GlobalServiceRegister.getDefault().getService(ICamelDesignerCoreService.class);
            if (service.isInstanceofCamel(process[0].getItem())) {
                useBeans = true;
            }
        }
        String includePath;
        String jar;
        if (useBeans) {
            includePath = USER_BEANS_PATH;
            jar = USERBEANS_JAR;
        } else {
            includePath = USER_ROUTINES_PATH;
            jar = USERROUTINE_JAR;
        }
        List<URL> urlList = new ArrayList<URL>();
        File jarFile = new File(getTmpFolder() + File.separatorChar + jar);
        // make a jar file of user routine or bean classes
        File classRootFileLocation = getClassRootFileLocation();
        if (classRootFileLocation == null) {
            return Collections.emptyList();
        }
        JarBuilder jarbuilder = new JarBuilder(classRootFileLocation, jarFile);
        jarbuilder.setIncludeDir(Collections.singleton(includePath));
        jarbuilder.setIncludeRoutines(getRoutineDependince(process, false, includePath));
        jarbuilder.setExcludeDir(// remove all
        Arrays.asList(// remove all
        SYSTEM_ROUTINES_PATH, // remove all
        USER_ROUTINES_PATH, USER_BEANS_PATH, USER_PIGUDF_PATH));
        jarbuilder.buildJar();
        urlList.add(jarFile.toURI().toURL());
        return urlList;
    } catch (Exception e) {
        ExceptionHandler.process(e);
        return Collections.emptyList();
    }
}
Also used : ICamelDesignerCoreService(org.talend.designer.core.ICamelDesignerCoreService) ArrayList(java.util.ArrayList) IFile(org.eclipse.core.resources.IFile) File(java.io.File) URL(java.net.URL) CoreException(org.eclipse.core.runtime.CoreException) IOException(java.io.IOException) DocumentException(org.dom4j.DocumentException) ProcessorException(org.talend.designer.runprocess.ProcessorException) MalformedURLException(java.net.MalformedURLException) PersistenceException(org.talend.commons.exception.PersistenceException)

Aggregations

ICamelDesignerCoreService (org.talend.designer.core.ICamelDesignerCoreService)11 PersistenceException (org.talend.commons.exception.PersistenceException)5 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)5 ArrayList (java.util.ArrayList)4 ProcessItem (org.talend.core.model.properties.ProcessItem)4 MalformedURLException (java.net.MalformedURLException)3 URL (java.net.URL)3 IFile (org.eclipse.core.resources.IFile)3 EConnectionType (org.talend.core.model.process.EConnectionType)3 INodeConnector (org.talend.core.model.process.INodeConnector)3 Property (org.talend.core.model.properties.Property)3 File (java.io.File)2 IOException (java.io.IOException)2 HashSet (java.util.HashSet)2 LinkedHashSet (java.util.LinkedHashSet)2 List (java.util.List)2 DocumentException (org.dom4j.DocumentException)2 IFolder (org.eclipse.core.resources.IFolder)2 CoreException (org.eclipse.core.runtime.CoreException)2 Point (org.eclipse.draw2d.geometry.Point)2