Search in sources :

Example 11 with Project

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

the class FixUnevenItemContextParametersMigrationTaskTest 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)

Example 12 with Project

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

the class JobScriptsManager method getTmpFolderPath.

private 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");
    }
    //$NON-NLS-1$
    tmpFolder = tmpFolder + "/talendExporter";
    return tmpFolder;
}
Also used : Project(org.talend.core.model.general.Project) ITalendProcessJavaProject(org.talend.core.runtime.process.ITalendProcessJavaProject) IProject(org.eclipse.core.resources.IProject) IProject(org.eclipse.core.resources.IProject) CoreException(org.eclipse.core.runtime.CoreException) ProcessorException(org.talend.designer.runprocess.ProcessorException) IOException(java.io.IOException)

Example 13 with Project

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

the class StormJobJavaScriptsManager method getTmpFolderPath.

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

Example 14 with Project

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

the class UserComponentsProviderTest method test_preComponentsLoad_oldComponentsInProject_Zip.

@Test
public void test_preComponentsLoad_oldComponentsInProject_Zip() throws Exception {
    File testDataFile = getTestDataFile(PATH_OLD_COMPONENT);
    Assert.assertTrue(testDataFile.exists());
    final Project currentProject = ProjectManager.getInstance().getCurrentProject();
    final IProject project = ResourceUtils.getProject(currentProject);
    final IFolder projectComponentsFolder = project.getFolder(ERepositoryObjectType.getFolderName(ERepositoryObjectType.COMPONENTS));
    Assert.assertTrue(projectComponentsFolder.exists());
    FilesUtils.copyFile(testDataFile, new File(projectComponentsFolder.getLocation().toFile(), testDataFile.getName()));
    UserComponentsProviderTestClass provider = new UserComponentsProviderTestClass() {

        protected File getExternalComponentsLocation() {
            return workFolder;
        }
    };
    provider.preComponentsLoad();
    testEmpty(provider);
}
Also used : Project(org.talend.core.model.general.Project) IProject(org.eclipse.core.resources.IProject) File(java.io.File) IProject(org.eclipse.core.resources.IProject) IFolder(org.eclipse.core.resources.IFolder) Test(org.junit.Test)

Example 15 with Project

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

the class UserComponentsProviderTest method test_preComponentsLoad_oldComponentsInProject_Folder.

@Test
public void test_preComponentsLoad_oldComponentsInProject_Folder() throws Exception {
    final String componentName = "tHTMLInput";
    File testDataFile = getTestDataFile(PATH_OLD_COMPONENT);
    Assert.assertTrue(testDataFile.exists());
    final Project currentProject = ProjectManager.getInstance().getCurrentProject();
    final IProject project = ResourceUtils.getProject(currentProject);
    final IFolder projectComponentsFolder = project.getFolder(ERepositoryObjectType.getFolderName(ERepositoryObjectType.COMPONENTS));
    Assert.assertTrue(projectComponentsFolder.exists());
    FilesUtils.unzip(testDataFile.getAbsolutePath(), projectComponentsFolder.getLocation().toFile().getAbsolutePath());
    UserComponentsProviderTestClass provider = new UserComponentsProviderTestClass() {

        protected File getExternalComponentsLocation() {
            return workFolder;
        }
    };
    provider.preComponentsLoad();
    File installationFolder = provider.getInstallationFolder();
    Assert.assertTrue(installationFolder.exists());
    Assert.assertEquals(1, installationFolder.list().length);
    File compFolder = new File(installationFolder, componentName);
    Assert.assertTrue(compFolder.exists());
    Assert.assertTrue(new File(compFolder, componentName + "_java.xml").exists());
}
Also used : Project(org.talend.core.model.general.Project) IProject(org.eclipse.core.resources.IProject) File(java.io.File) IProject(org.eclipse.core.resources.IProject) IFolder(org.eclipse.core.resources.IFolder) Test(org.junit.Test)

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