Search in sources :

Example 6 with Project

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

the class ExportJobUtil method getTmpFolderPath.

public static String getTmpFolderPath() {
    Project project = ProjectManager.getInstance().getCurrentProject();
    String tmpFolder;
    try {
        IProject physProject = ResourceModelUtils.getProject(project);
        //$NON-NLS-1$
        tmpFolder = physProject.getFolder("temp").getLocation().toPortableString();
    } catch (Exception e) {
        //$NON-NLS-1$
        tmpFolder = System.getProperty("user.dir");
    }
    return tmpFolder;
}
Also used : Project(org.talend.core.model.general.Project) IProject(org.eclipse.core.resources.IProject) IProject(org.eclipse.core.resources.IProject)

Example 7 with Project

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

the class JobJavaScriptOSGIForESBManager method createAnalyzer.

protected Analyzer createAnalyzer(ExportFileResource libResource, ProcessItem processItem) throws IOException {
    Analyzer analyzer = new Analyzer();
    Jar bin = new Jar(classesLocation);
    analyzer.setJar(bin);
    final String bundleName = processItem.getProperty().getLabel();
    String symbolicName = bundleName;
    // http://jira.talendforge.org/browse/TESB-5382 LiXiaopeng
    Project project = ProjectManager.getInstance().getCurrentProject();
    if (project != null) {
        String proName = project.getLabel();
        if (proName != null) {
            symbolicName = proName.toLowerCase() + '.' + symbolicName;
        }
    }
    analyzer.setProperty(Analyzer.BUNDLE_NAME, bundleName);
    analyzer.setProperty(Analyzer.BUNDLE_SYMBOLICNAME, symbolicName);
    analyzer.setProperty(Analyzer.BUNDLE_VERSION, getBundleVersion());
    IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
    analyzer.setProperty(Analyzer.BUNDLE_VENDOR, //$NON-NLS-1$
    brandingService.getFullProductName() + " (" + brandingService.getAcronym() + '_' + RepositoryPlugin.getDefault().getBundle().getVersion().toString() + //$NON-NLS-1$
    ")");
    addOsgiDependencies(analyzer, libResource, processItem);
    //$NON-NLS-1$
    final StringBuilder bundleClasspath = new StringBuilder(".");
    final StringBuilder bundleNativeCode = new StringBuilder();
    Set<String> relativePathList = libResource.getRelativePathList();
    for (String path : relativePathList) {
        Set<URL> resources = libResource.getResourcesByRelativePath(path);
        for (URL url : resources) {
            File dependencyFile = new File(FilesUtils.getFileRealPath(url.getPath()));
            String relativePath = libResource.getDirectoryName() + PATH_SEPARATOR + dependencyFile.getName();
            bundleClasspath.append(MANIFEST_ITEM_SEPARATOR).append(relativePath);
            bin.putResource(relativePath, new FileResource(dependencyFile));
            // Add dynamic library declaration in manifest
            if (relativePath.toLowerCase().endsWith(DLL_FILE) || relativePath.toLowerCase().endsWith(SO_FILE)) {
                bundleNativeCode.append(libResource.getDirectoryName() + PATH_SEPARATOR + dependencyFile.getName()).append(OSGI_OS_CODE);
            }
        }
    }
    analyzer.setProperty(Analyzer.BUNDLE_CLASSPATH, bundleClasspath.toString());
    // TESB-15680: Add Bundle-NativeCode in manifest
    if (bundleNativeCode.length() > 0) {
        bundleNativeCode.setLength(bundleNativeCode.length() - 1);
        analyzer.setProperty(Analyzer.BUNDLE_NATIVECODE, bundleNativeCode.toString());
    }
    return analyzer;
}
Also used : Project(org.talend.core.model.general.Project) ITalendProcessJavaProject(org.talend.core.runtime.process.ITalendProcessJavaProject) FileResource(aQute.bnd.osgi.FileResource) ExportFileResource(org.talend.repository.documentation.ExportFileResource) Jar(aQute.bnd.osgi.Jar) IBrandingService(org.talend.core.ui.branding.IBrandingService) Analyzer(aQute.bnd.osgi.Analyzer) File(java.io.File) URL(java.net.URL)

Example 8 with Project

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

the class PublishMetadataRunnable method getTempFile.

private File getTempFile(InputStream inputStream) throws PersistenceException, IOException, CoreException {
    Project project = ProjectManager.getInstance().getCurrentProject();
    IProject fsProject = null;
    fsProject = ResourceUtils.getProject(project);
    IPath path = new Path("temp");
    String name = File.createTempFile("tESBConsumer", ".wsdl").getName();
    path = path.append(name);
    IFile file = fsProject.getFile(path);
    file.create(inputStream, false, new NullProgressMonitor());
    return new File(file.getLocation().toPortableString());
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) Project(org.talend.core.model.general.Project) IProject(org.eclipse.core.resources.IProject) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IFile(org.eclipse.core.resources.IFile) IPath(org.eclipse.core.runtime.IPath) IFile(org.eclipse.core.resources.IFile) File(java.io.File) IProject(org.eclipse.core.resources.IProject)

Example 9 with Project

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

the class DemosImportTest method createTempDemoProject.

protected void createTempDemoProject(String demoName) throws CoreException, PersistenceException {
    Project projectInfor = new Project();
    projectInfor.setLabel(demoName);
    projectInfor.setDescription("no desc");
    projectInfor.setLanguage(ECodeLanguage.JAVA);
    User user = PropertiesFactory.eINSTANCE.createUser();
    user.setLogin("testauto@talend.com");
    projectInfor.setAuthor(user);
    IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
    String technicalLabel = Project.createTechnicalName(projectInfor.getLabel());
    IProject prj = root.getProject(technicalLabel);
    final IWorkspace workspace = ResourcesPlugin.getWorkspace();
    try {
        IProjectDescription desc = null;
        if (prj.exists()) {
            // always delete to avoid conflicts between 2 tests
            prj.delete(true, null);
        }
        desc = workspace.newProjectDescription(technicalLabel);
        desc.setNatureIds(new String[] { TalendNature.ID });
        desc.setComment(projectInfor.getDescription());
        prj.create(desc, null);
        prj.open(IResource.DEPTH_INFINITE, null);
        prj.setDefaultCharset("UTF-8", null);
    } catch (CoreException e) {
        throw new PersistenceException(e);
    }
    tempDemoProject = new Project();
    // Fill project object
    tempDemoProject.setLabel(projectInfor.getLabel());
    tempDemoProject.setDescription(projectInfor.getDescription());
    tempDemoProject.setLanguage(projectInfor.getLanguage());
    tempDemoProject.setAuthor(projectInfor.getAuthor());
    tempDemoProject.setLocal(true);
    tempDemoProject.setTechnicalLabel(technicalLabel);
    XmiResourceManager xmiResourceManager = new XmiResourceManager();
    Resource projectResource = xmiResourceManager.createProjectResource(prj);
    projectResource.getContents().add(tempDemoProject.getEmfProject());
    projectResource.getContents().add(tempDemoProject.getAuthor());
    xmiResourceManager.saveResource(projectResource);
}
Also used : IProject(org.eclipse.core.resources.IProject) Project(org.talend.core.model.general.Project) User(org.talend.core.model.properties.User) IWorkspaceRoot(org.eclipse.core.resources.IWorkspaceRoot) CoreException(org.eclipse.core.runtime.CoreException) IWorkspace(org.eclipse.core.resources.IWorkspace) IProjectDescription(org.eclipse.core.resources.IProjectDescription) PersistenceException(org.talend.commons.exception.PersistenceException) IResource(org.eclipse.core.resources.IResource) Resource(org.eclipse.emf.ecore.resource.Resource) XmiResourceManager(org.talend.core.repository.utils.XmiResourceManager) IProject(org.eclipse.core.resources.IProject)

Example 10 with Project

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

the class AddContextCommentValueMigrationTaskTest method createTempProject.

private static void createTempProject() throws CoreException, PersistenceException, LoginException {
    Project projectInfor = new Project();
    projectInfor.setLabel("testauto");
    projectInfor.setDescription("no desc");
    projectInfor.setLanguage(ECodeLanguage.JAVA);
    User user = PropertiesFactory.eINSTANCE.createUser();
    user.setLogin("testauto@talend.com");
    projectInfor.setAuthor(user);
    IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
    String technicalLabel = Project.createTechnicalName(projectInfor.getLabel());
    IProject prj = root.getProject(technicalLabel);
    final IWorkspace workspace = ResourcesPlugin.getWorkspace();
    try {
        IProjectDescription desc = null;
        if (prj.exists()) {
            // always delete to avoid conflicts between 2 tests
            prj.delete(true, null);
        }
        desc = workspace.newProjectDescription(technicalLabel);
        desc.setNatureIds(new String[] { TalendNature.ID });
        desc.setComment(projectInfor.getDescription());
        prj.create(desc, null);
        prj.open(IResource.DEPTH_INFINITE, null);
        prj.setDefaultCharset("UTF-8", null);
    } catch (CoreException e) {
        throw new PersistenceException(e);
    }
    sampleProject = new Project();
    // Fill project object
    sampleProject.setLabel(projectInfor.getLabel());
    sampleProject.setDescription(projectInfor.getDescription());
    sampleProject.setLanguage(projectInfor.getLanguage());
    sampleProject.setAuthor(projectInfor.getAuthor());
    sampleProject.setLocal(true);
    sampleProject.setTechnicalLabel(technicalLabel);
    XmiResourceManager xmiResourceManager = new XmiResourceManager();
    Resource projectResource = xmiResourceManager.createProjectResource(prj);
    projectResource.getContents().add(sampleProject.getEmfProject());
    projectResource.getContents().add(sampleProject.getAuthor());
    xmiResourceManager.saveResource(projectResource);
}
Also used : IProject(org.eclipse.core.resources.IProject) Project(org.talend.core.model.general.Project) User(org.talend.core.model.properties.User) IWorkspaceRoot(org.eclipse.core.resources.IWorkspaceRoot) CoreException(org.eclipse.core.runtime.CoreException) IWorkspace(org.eclipse.core.resources.IWorkspace) IProjectDescription(org.eclipse.core.resources.IProjectDescription) PersistenceException(org.talend.commons.exception.PersistenceException) IResource(org.eclipse.core.resources.IResource) Resource(org.eclipse.emf.ecore.resource.Resource) XmiResourceManager(org.talend.core.repository.utils.XmiResourceManager) IProject(org.eclipse.core.resources.IProject)

Aggregations

Project (org.talend.core.model.general.Project)160 IProject (org.eclipse.core.resources.IProject)77 PersistenceException (org.talend.commons.exception.PersistenceException)73 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)34 ArrayList (java.util.ArrayList)24 IFolder (org.eclipse.core.resources.IFolder)23 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)23 Property (org.talend.core.model.properties.Property)21 File (java.io.File)20 Path (org.eclipse.core.runtime.Path)19 ProxyRepositoryFactory (org.talend.core.repository.model.ProxyRepositoryFactory)19 IPath (org.eclipse.core.runtime.IPath)18 IOException (java.io.IOException)17 RepositoryContext (org.talend.core.context.RepositoryContext)16 CoreException (org.eclipse.core.runtime.CoreException)14 ERepositoryObjectType (org.talend.core.model.repository.ERepositoryObjectType)14 IFile (org.eclipse.core.resources.IFile)13 Item (org.talend.core.model.properties.Item)13 User (org.talend.core.model.properties.User)13 Test (org.junit.Test)12