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);
}
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;
}
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;
}
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);
}
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());
}
Aggregations