Search in sources :

Example 26 with ITalendProcessJavaProject

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

the class JavaRoutineSynchronizer method getTestContainerFile.

private IFile getTestContainerFile(ProcessItem item, String projectFolderName, String folderName, String jobName) {
    IRunProcessService service = CodeGeneratorActivator.getDefault().getRunProcessService();
    ITalendProcessJavaProject talendProcessJavaProject = service.getTalendProcessJavaProject();
    if (talendProcessJavaProject == null) {
        return null;
    }
    IFolder srcFolder = talendProcessJavaProject.getTestSrcFolder();
    String packageName = JavaResourcesHelper.getJobClassPackageFolder(item, true);
    IFile file = srcFolder.getFile(packageName + '/' + jobName + "Test" + JavaUtils.JAVA_EXTENSION);
    return file;
}
Also used : IFile(org.eclipse.core.resources.IFile) IRunProcessService(org.talend.designer.runprocess.IRunProcessService) ITalendProcessJavaProject(org.talend.core.runtime.process.ITalendProcessJavaProject) IFolder(org.eclipse.core.resources.IFolder)

Example 27 with ITalendProcessJavaProject

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

the class JavaRoutineSynchronizer method syncModule.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.designer.codegen.IRoutineSynchronizer#syncRoutine(org.talend .core.model.properties.RoutineItem)
     */
private static void syncModule(File[] modules) throws SystemException {
    IRunProcessService service = CodeGeneratorActivator.getDefault().getRunProcessService();
    ITalendProcessJavaProject talendProcessJavaProject = service.getTalendProcessJavaProject();
    if (talendProcessJavaProject == null) {
        return;
    }
    final IFolder systemFolder = talendProcessJavaProject.getSrcSubFolder(null, JavaUtils.JAVA_ROUTINES_DIRECTORY + '/' + JavaUtils.JAVA_SYSTEM_DIRECTORY);
    syncModules(modules, systemFolder);
}
Also used : IRunProcessService(org.talend.designer.runprocess.IRunProcessService) ITalendProcessJavaProject(org.talend.core.runtime.process.ITalendProcessJavaProject) IFolder(org.eclipse.core.resources.IFolder)

Example 28 with ITalendProcessJavaProject

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

the class TalendDefaultJavaEditor method doSetInput.

@Override
protected void doSetInput(IEditorInput input) throws CoreException {
    if (input instanceof FileEditorInput) {
        try {
            // IRepositoryService repositoryService = DesignerPlugin.getDefault().getRepositoryService();
            // IProxyRepositoryFactory repFactory = repositoryService.getProxyRepositoryFactory();
            IRunProcessService runProcessService = (IRunProcessService) GlobalServiceRegister.getDefault().getService(IRunProcessService.class);
            // I think runProcessService can't be null, and should throw exception if it is null
            ITalendProcessJavaProject talendJavaProject = runProcessService.getTalendProcessJavaProject();
            if (talendJavaProject == null) {
                return;
            }
            //$NON-NLS-1$
            final String pathSeperator = "/";
            String routinesFolderName = ERepositoryObjectType.ROUTINES.getFolder().split(pathSeperator)[1];
            String talendSrcFolderPath = talendJavaProject.getSrcFolder().getLocation().toString() + pathSeperator;
            String routineFolderPath = talendSrcFolderPath + routinesFolderName + pathSeperator;
            IFile openedFile = ((FileEditorInput) input).getFile();
            String openedFilePath = openedFile.getLocation().toString();
            boolean isRoutine = openedFilePath.startsWith(routineFolderPath);
            boolean isTalendGeneratedFile = openedFilePath.startsWith(talendSrcFolderPath);
            //$NON-NLS-1$
            String systemRoutineFolderName = "system";
            String systemRoutineFolderPath = routineFolderPath + systemRoutineFolderName + pathSeperator;
            boolean isSystemRoutine = openedFilePath.startsWith(systemRoutineFolderPath);
            if (isSystemRoutine) {
                fileType = FILE_TYPE_TALEND_GENERATED_READONLY;
            } else if (isRoutine) {
                fileType = FILE_TYPE_TALEND_GENERATED_READONLY;
            } else if (isTalendGeneratedFile) {
                fileType = FILE_TYPE_TALEND_GENERATED_READONLY;
            } else {
                fileType = FILE_TYPE_OTHERS;
            }
        } catch (Throwable e) {
            CommonExceptionHandler.process(e, Priority.WARN);
            fileType = FILE_TYPE_OTHERS;
        }
    }
    super.doSetInput(input);
}
Also used : IFile(org.eclipse.core.resources.IFile) FileEditorInput(org.eclipse.ui.part.FileEditorInput) IRunProcessService(org.talend.designer.runprocess.IRunProcessService) ITalendProcessJavaProject(org.talend.core.runtime.process.ITalendProcessJavaProject)

Example 29 with ITalendProcessJavaProject

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

the class GenerateGrammarController method addReferenceJavaFile.

/**
     * Store file to file system. Actually, it locates src/routines/xx DOC ytao Comment method "addReferenceJavaFile".
     * 
     * @param routineItem
     * @param copyToTemp
     * @return
     * @throws SystemException
     */
private IFile addReferenceJavaFile(RoutineItem routineItem, boolean copyToTemp) throws SystemException {
    FileOutputStream fos = null;
    try {
        IRunProcessService service = DesignerPlugin.getDefault().getRunProcessService();
        ITalendProcessJavaProject talendProcessJavaProject = service.getTalendProcessJavaProject();
        if (talendProcessJavaProject == null) {
            return null;
        }
        String label = routineItem.getProperty().getLabel();
        IFile file = talendProcessJavaProject.getSrcFolder().getFile(JavaUtils.JAVA_ROUTINES_DIRECTORY + '/' + label + JavaUtils.JAVA_EXTENSION);
        if (copyToTemp) {
            String routineContent = new String(routineItem.getContent().getInnerContent());
            if (!label.equals(ITalendSynchronizer.TEMPLATE)) {
                routineContent = routineContent.replaceAll(ITalendSynchronizer.TEMPLATE, label);
                File f = file.getLocation().toFile();
                fos = new FileOutputStream(f);
                fos.write(routineContent.getBytes());
                fos.close();
            }
        }
        if (!file.exists()) {
            file.refreshLocal(1, null);
        }
        return file;
    } catch (Exception e) {
        throw new SystemException(e);
    } finally {
        try {
            fos.close();
        } catch (Exception e) {
            // ignore me even if i'm null
            ExceptionHandler.process(e);
        }
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) SystemException(org.talend.commons.exception.SystemException) FileOutputStream(java.io.FileOutputStream) IRunProcessService(org.talend.designer.runprocess.IRunProcessService) IFile(org.eclipse.core.resources.IFile) File(java.io.File) ITalendProcessJavaProject(org.talend.core.runtime.process.ITalendProcessJavaProject) SystemException(org.talend.commons.exception.SystemException) IOException(java.io.IOException)

Example 30 with ITalendProcessJavaProject

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

the class JavaProcessor method getBasePathClasspath.

protected String getBasePathClasspath() throws ProcessorException {
    final String classPathSeparator = extractClassPathSeparator();
    final String rootWorkingDir = getRootWorkingDir(false);
    StringBuffer basePath = new StringBuffer(50);
    if (isExportConfig() || isRunAsExport()) {
        // current path.
        basePath.append('.');
        if (rootWorkingDir.length() > 0) {
            basePath.append(classPathSeparator);
            // $ROOT_PATH
            basePath.append(rootWorkingDir);
        }
        if (isExternalUse()) {
            // for tRunJob with independent option and init pom for classpath
            List<String> codesJars = PomUtil.getCodesExportJars(this.getProcess());
            for (String codesJar : codesJars) {
                basePath.append(classPathSeparator);
                if (rootWorkingDir.length() > 0) {
                    basePath.append(rootWorkingDir);
                    basePath.append(JavaUtils.PATH_SEPARATOR);
                }
                basePath.append(getBaseLibPath());
                basePath.append(JavaUtils.PATH_SEPARATOR);
                basePath.append(codesJar);
            }
        } else {
            String outputPath = getCodeLocation();
            if (outputPath != null) {
                outputPath = outputPath.replace(ProcessorUtilities.TEMP_JAVA_CLASSPATH_SEPARATOR, classPathSeparator);
                if (outputPath.endsWith(classPathSeparator)) {
                    // remove the seperator
                    outputPath = outputPath.substring(0, outputPath.length() - 1);
                }
                if (!Platform.OS_WIN32.equals(getTargetPlatform())) {
                    String libraryPath = ProcessorUtilities.getLibraryPath();
                    if (libraryPath != null) {
                        String unixRootPath = getRootWorkingDir(true);
                        outputPath = outputPath.replace(libraryPath, unixRootPath + libraryPath);
                    }
                }
            }
            basePath.append(classPathSeparator);
            basePath.append(outputPath);
        }
        // FIXME for old build (JobJavaScriptsManager) temp, when "ProcessorUtilities.setExportConfig(dir,true)"
        String codeLocation = getCodeLocation();
        if (codeLocation != null && codeLocation.contains(JavaUtils.SYSTEM_ROUTINE_JAR) && codeLocation.contains(JavaUtils.USER_ROUTINE_JAR) && !basePath.toString().contains(JavaUtils.SYSTEM_ROUTINE_JAR)) {
            basePath.append(classPathSeparator);
            codeLocation = codeLocation.replace(ProcessorUtilities.TEMP_JAVA_CLASSPATH_SEPARATOR, classPathSeparator);
            basePath.append(codeLocation);
        }
    } else {
        ITalendProcessJavaProject tProcessJvaProject = this.getTalendJavaProject();
        IFolder classesFolder = tProcessJvaProject.getOutputFolder();
        String outputPath = classesFolder.getLocation().toPortableString();
        // add current path
        outputPath += classPathSeparator + '.';
        basePath.append(outputPath);
    }
    return basePath.toString();
}
Also used : ITalendProcessJavaProject(org.talend.core.runtime.process.ITalendProcessJavaProject) 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