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