Search in sources :

Example 21 with ITalendProcessJavaProject

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

the class AbstractStandardJobBuildProviderTest method test_createPomCreator_nullItem.

@Test
public void test_createPomCreator_nullItem() {
    Map<String, Object> parameters = new HashMap<String, Object>();
    parameters.put(IBuildPomCreatorParameters.PROCESSOR, new TestProcessor());
    ITalendProcessJavaProject talendProcessJavaProject = RepositoryPlugin.getDefault().getRunProcessService().getTalendProcessJavaProject();
    parameters.put(IBuildPomCreatorParameters.FILE_POM, talendProcessJavaProject.getProject().getFile("pom_abc.xml"));
    RepositoryObjectTypeBuildProvider provider = createTestBuildProvider();
    Assert.assertNull(provider.createPomCreator(parameters));
}
Also used : HashMap(java.util.HashMap) RepositoryObjectTypeBuildProvider(org.talend.core.runtime.repository.build.RepositoryObjectTypeBuildProvider) ITalendProcessJavaProject(org.talend.core.runtime.process.ITalendProcessJavaProject) Test(org.junit.Test)

Example 22 with ITalendProcessJavaProject

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

the class RouteJavaScriptOSGIForESBManager method addOsgiDependencies.

@Override
protected void addOsgiDependencies(Analyzer analyzer, ExportFileResource libResource, ProcessItem processItem) throws IOException {
    final DependenciesResolver resolver = new DependenciesResolver(processItem);
    //exportPackage.append(getPackageName(processItem));
    // Add Route Resource Export packages
    // http://jira.talendforge.org/browse/TESB-6227
    // add manifest items
    analyzer.setProperty(Analyzer.REQUIRE_BUNDLE, resolver.getManifestRequireBundle(MANIFEST_ITEM_SEPARATOR));
    analyzer.setProperty(Analyzer.IMPORT_PACKAGE, //$NON-NLS-1$
    resolver.getManifestImportPackage(MANIFEST_ITEM_SEPARATOR) + ",*;resolution:=optional");
    analyzer.setProperty(Analyzer.EXPORT_PACKAGE, resolver.getManifestExportPackage(MANIFEST_ITEM_SEPARATOR));
    if (GlobalServiceRegister.getDefault().isServiceRegistered(IRunProcessService.class)) {
        IRunProcessService processService = (IRunProcessService) GlobalServiceRegister.getDefault().getService(IRunProcessService.class);
        ITalendProcessJavaProject talendProcessJavaProject = processService.getTalendProcessJavaProject();
        if (talendProcessJavaProject != null) {
            final IPath libPath = talendProcessJavaProject.getLibFolder().getLocation();
            // process external libs
            final List<URL> list = new ArrayList<URL>();
            for (String s : resolver.getManifestBundleClasspath(MANIFEST_ITEM_SEPARATOR).split(Character.toString(MANIFEST_ITEM_SEPARATOR))) {
                if (!s.isEmpty()) {
                    list.add(libPath.append(s).toFile().toURI().toURL());
                }
            }
            libResource.addResources(list);
        }
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) IRunProcessService(org.talend.designer.runprocess.IRunProcessService) DependenciesResolver(org.talend.designer.camel.dependencies.core.DependenciesResolver) ArrayList(java.util.ArrayList) ITalendProcessJavaProject(org.talend.core.runtime.process.ITalendProcessJavaProject) URL(java.net.URL)

Example 23 with ITalendProcessJavaProject

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

the class RouteResourceUtil method synchronizeRouteResource.

public static Collection<IPath> synchronizeRouteResource(final ProcessItem item) {
    final boolean routelet;
    if (item.eClass() == CamelPropertiesPackage.Literals.CAMEL_PROCESS_ITEM) {
        routelet = false;
    } else if (item.eClass() == CamelPropertiesPackage.Literals.ROUTELET_PROCESS_ITEM) {
        routelet = true;
    } else {
        return null;
    }
    if (!GlobalServiceRegister.getDefault().isServiceRegistered(IRunProcessService.class)) {
        return null;
    }
    final IRunProcessService processService = (IRunProcessService) GlobalServiceRegister.getDefault().getService(IRunProcessService.class);
    final ITalendProcessJavaProject talendProcessJavaProject = processService.getTalendProcessJavaProject();
    if (talendProcessJavaProject == null) {
        return null;
    }
    final IFolder routeResourceFolder = talendProcessJavaProject.getResourcesFolder();
    final Collection<IPath> result = new ArrayList<IPath>();
    // add spring file
    if (!routelet) {
        final IFolder metaInf = routeResourceFolder.getFolder("META-INF/spring/");
        try {
            prepareFolder(metaInf);
            final IFile spring = metaInf.getFile(item.getProperty().getLabel().toLowerCase() + ".xml");
            final InputStream inputStream = new ByteArrayInputStream(((CamelProcessItem) item).getSpringContent().getBytes());
            if (spring.exists()) {
                spring.setContents(inputStream, 0, null);
            } else {
                spring.create(inputStream, true, null);
            }
            result.add(spring.getLocation());
        } catch (CoreException e) {
            ExceptionHandler.process(e);
        }
    }
    for (ResourceDependencyModel model : getResourceDependencies(item)) {
        IFile file = copyResources(routeResourceFolder, model);
        if (file != null) {
            result.add(file.getLocation());
        }
    }
    return result;
}
Also used : IFile(org.eclipse.core.resources.IFile) IPath(org.eclipse.core.runtime.IPath) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) ResourceDependencyModel(org.talend.designer.camel.resource.core.model.ResourceDependencyModel) IRunProcessService(org.talend.designer.runprocess.IRunProcessService) ArrayList(java.util.ArrayList) ITalendProcessJavaProject(org.talend.core.runtime.process.ITalendProcessJavaProject) CoreException(org.eclipse.core.runtime.CoreException) ByteArrayInputStream(java.io.ByteArrayInputStream) CamelProcessItem(org.talend.camel.core.model.camelProperties.CamelProcessItem) IFolder(org.eclipse.core.resources.IFolder)

Example 24 with ITalendProcessJavaProject

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

the class TalendJavaSourceViewer method updateContents.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.core.ui.viewer.ReconcilerViewer#setContents(org.eclipse.jface.text.IDocument)
     */
@Override
public void updateContents() {
    if (getDocument() == null) {
        return;
    }
    InputStream codeStream = new ByteArrayInputStream(getDocument().get().getBytes());
    try {
        IRunProcessService runProcessService = getRunProcessService();
        if (file == null && runProcessService != null) {
            ITalendProcessJavaProject talendProcessJavaProject = runProcessService.getTalendProcessJavaProject();
            if (talendProcessJavaProject == null) {
                return;
            }
            file = talendProcessJavaProject.getSrcFolder().getFile(JavaUtils.JAVA_INTERNAL_DIRECTORY + '/' + filename);
            file.setContents(codeStream, true, false, null);
            initializeModel();
        } else {
            // only happen sometimes with a "fast click" (file don't exist yet).
            if (getViewerRegion().getLength() == 0) {
                return;
            } else {
                file.setContents(codeStream, true, false, null);
            }
        }
    } catch (CoreException e) {
    // don't display any error.
    }
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) IRunProcessService(org.talend.designer.runprocess.IRunProcessService) ITalendProcessJavaProject(org.talend.core.runtime.process.ITalendProcessJavaProject)

Example 25 with ITalendProcessJavaProject

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

the class JavaSQLPatternSynchronizer method getSQLPatternFile.

/*
     * (non-Javadoc)
     * 
     * @see
     * org.talend.designer.codegen.ISQLPatternSynchronizer#getSQLPattern(org.talend.core.model.properties.SQLPatternItem
     * )
     */
@Override
public IFile getSQLPatternFile(SQLPatternItem item) throws SystemException {
    IRunProcessService service = CodeGeneratorActivator.getDefault().getRunProcessService();
    ITalendProcessJavaProject talendProcessJavaProject = service.getTalendProcessJavaProject();
    if (talendProcessJavaProject == null) {
        return null;
    }
    String basePath = JavaUtils.JAVA_SQLPATTERNS_DIRECTORY + '/' + item.getEltName();
    // init user defined folder
    talendProcessJavaProject.getResourceSubFolder(null, basePath + '/' + JavaUtils.JAVA_USER_DEFINED);
    IFolder systemFolder = talendProcessJavaProject.getResourceSubFolder(null, basePath + '/' + JavaUtils.JAVA_SYSTEM_DIRECTORY);
    IFile file = systemFolder.getFile(item.getProperty().getLabel() + JavaUtils.JAVA_SQLPATTERN_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)

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