Search in sources :

Example 46 with ITalendProcessJavaProject

use of org.talend.core.runtime.process.ITalendProcessJavaProject in project tdi-studio-se by Talend.

the class JobScriptsManager method getCorrespondingProjectRootPath.

/**
     * ggu Comment method "getCorrespondingProjectRootPath".
     * 
     * if item is null, will return currrent probject path.
     */
protected IPath getCorrespondingProjectRootPath(Item item) throws Exception {
    // for bug 17685
    org.talend.core.model.properties.Project p = ProjectManager.getInstance().getProject(item);
    IProject project = null;
    if (p != null) {
        project = ResourcesPlugin.getWorkspace().getRoot().getProject(p.getTechnicalLabel().toUpperCase());
        if (project != null) {
            return project.getLocation();
        }
    }
    // maybe, not used
    ITalendProcessJavaProject talendProcessJavaProject = RepositoryPlugin.getDefault().getRunProcessService().getTalendProcessJavaProject();
    if (talendProcessJavaProject == null) {
        //$NON-NLS-1$
        return new Path("");
    }
    project = talendProcessJavaProject.getProject();
    IPath root = project.getParent().getLocation().append(getCorrespondingProjectName(item).toUpperCase());
    return root;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IPath(org.eclipse.core.runtime.IPath) IProject(org.eclipse.core.resources.IProject) ITalendProcessJavaProject(org.talend.core.runtime.process.ITalendProcessJavaProject)

Example 47 with ITalendProcessJavaProject

use of org.talend.core.runtime.process.ITalendProcessJavaProject in project tdi-studio-se by Talend.

the class JobJavaScriptsManager method getClassRootFileLocation.

protected File getClassRootFileLocation() {
    ITalendProcessJavaProject talendProcessJavaProject = RepositoryPlugin.getDefault().getRunProcessService().getTalendProcessJavaProject();
    if (talendProcessJavaProject == null) {
        return null;
    }
    IFolder outputFolder = talendProcessJavaProject.getOutputFolder();
    return outputFolder.getLocation().toFile();
}
Also used : ITalendProcessJavaProject(org.talend.core.runtime.process.ITalendProcessJavaProject) IFolder(org.eclipse.core.resources.IFolder)

Example 48 with ITalendProcessJavaProject

use of org.talend.core.runtime.process.ITalendProcessJavaProject in project tdi-studio-se by Talend.

the class JobJavaScriptsManager method addContextScripts.

/**
     * DOC acer Comment method "addContextScripts".
     * 
     * @param resource
     * @param boolean1
     */
protected void addContextScripts(ProcessItem processItem, String jobName, String jobVersion, ExportFileResource resource, Boolean needContext) {
    if (!needContext) {
        return;
    }
    List<URL> list = new ArrayList<URL>(1);
    String projectName = getCorrespondingProjectName(processItem);
    String folderName = JavaResourcesHelper.getJobFolderName(jobName, jobVersion);
    try {
        String jobPackagePath = projectName + PATH_SEPARATOR + folderName + PATH_SEPARATOR + JavaUtils.JAVA_CONTEXTS_DIRECTORY;
        ITalendProcessJavaProject talendProcessJavaProject = RepositoryPlugin.getDefault().getRunProcessService().getTalendProcessJavaProject();
        if (talendProcessJavaProject == null) {
            return;
        }
        IFolder outputFolder = talendProcessJavaProject.getOutputFolder();
        IFolder contextsFolder = outputFolder.getFolder(jobPackagePath);
        File contextDir = contextsFolder.getLocation().toFile();
        if (contextDir.isDirectory()) {
            list.addAll(getActiveContextFiles(contextDir.listFiles(), processItem));
        }
        // list.add(classRoot.toFile().toURL());
        resource.addResources(jobPackagePath, list);
    } catch (Exception e) {
        ExceptionHandler.process(e);
    }
}
Also used : ArrayList(java.util.ArrayList) IFile(org.eclipse.core.resources.IFile) File(java.io.File) URL(java.net.URL) ITalendProcessJavaProject(org.talend.core.runtime.process.ITalendProcessJavaProject) 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) IFolder(org.eclipse.core.resources.IFolder)

Example 49 with ITalendProcessJavaProject

use of org.talend.core.runtime.process.ITalendProcessJavaProject in project tdi-studio-se by Talend.

the class JobJavaScriptsManager method addLog4jSetting.

protected void addLog4jSetting(ExportFileResource resource) {
    try {
        if (Log4jPrefsSettingManager.getInstance().isLog4jEnable() && GlobalServiceRegister.getDefault().isServiceRegistered(IRunProcessService.class)) {
            IRunProcessService processService = (IRunProcessService) GlobalServiceRegister.getDefault().getService(IRunProcessService.class);
            ITalendProcessJavaProject talendProcessJavaProject = processService.getTalendProcessJavaProject();
            if (talendProcessJavaProject != null) {
                IFolder resourcesFolder = talendProcessJavaProject.getResourcesFolder();
                IFile log4jFile = resourcesFolder.getFile(Log4jPrefsConstants.LOG4J_FILE_NAME);
                if (log4jFile.exists()) {
                    List<URL> log4jFileUrls = new ArrayList<URL>();
                    log4jFileUrls.add(FileLocator.toFileURL(log4jFile.getLocationURI().toURL()));
                    resource.addResources(PATH_SEPARATOR, log4jFileUrls);
                }
            }
        }
    } catch (Exception e) {
        ExceptionHandler.process(e);
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) IRunProcessService(org.talend.designer.runprocess.IRunProcessService) ArrayList(java.util.ArrayList) ITalendProcessJavaProject(org.talend.core.runtime.process.ITalendProcessJavaProject) 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) IFolder(org.eclipse.core.resources.IFolder)

Aggregations

ITalendProcessJavaProject (org.talend.core.runtime.process.ITalendProcessJavaProject)49 IRunProcessService (org.talend.designer.runprocess.IRunProcessService)27 IFolder (org.eclipse.core.resources.IFolder)25 IFile (org.eclipse.core.resources.IFile)17 CoreException (org.eclipse.core.runtime.CoreException)16 IOException (java.io.IOException)12 File (java.io.File)11 ArrayList (java.util.ArrayList)11 IPath (org.eclipse.core.runtime.IPath)11 URL (java.net.URL)10 PersistenceException (org.talend.commons.exception.PersistenceException)9 MalformedURLException (java.net.MalformedURLException)8 HashMap (java.util.HashMap)8 ProcessorException (org.talend.designer.runprocess.ProcessorException)8 IProject (org.eclipse.core.resources.IProject)7 Test (org.junit.Test)7 RepositoryObjectTypeBuildProvider (org.talend.core.runtime.repository.build.RepositoryObjectTypeBuildProvider)7 DocumentException (org.dom4j.DocumentException)6 Path (org.eclipse.core.runtime.Path)5 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)4