use of org.talend.core.model.general.Project in project tdi-studio-se by Talend.
the class TosTokenCollector method priorCollect.
@Override
public void priorCollect() throws Exception {
// for all projects
JSONObject allProjectRecords = null;
IPreferenceStore preferenceStore = RepositoryPlugin.getDefault().getPreferenceStore();
String records = preferenceStore.getString(PREF_TOS_JOBS_RECORDS);
try {
// reset
allProjectRecords = new JSONObject(records);
} catch (Exception e) {
// the value is not set, or is empty
allProjectRecords = new JSONObject();
}
JSONObject currentProjectObject = collectProjectDetails();
Project currentProject = ProjectManager.getInstance().getCurrentProject();
allProjectRecords.put(currentProject.getTechnicalLabel(), currentProjectObject);
//
preferenceStore.setValue(PREF_TOS_JOBS_RECORDS, allProjectRecords.toString());
}
use of org.talend.core.model.general.Project in project tdi-studio-se by Talend.
the class NewProjectWizard method performFinish.
/**
* @see org.eclipse.jface.wizard.Wizard#performFinish()
*/
@Override
public boolean performFinish() {
IProxyRepositoryFactory repositoryFactory = ProxyRepositoryFactory.getInstance();
Context ctx = CorePlugin.getContext();
RepositoryContext repositoryContext = (RepositoryContext) ctx.getProperty(Context.REPOSITORY_CONTEXT_KEY);
try {
Project projectInfor = ProjectHelper.createProject(mainPage.getName().trim().replace(' ', '_'), mainPage.getDescription(), mainPage.getLanguage(), repositoryContext.getUser());
project = repositoryFactory.createProject(projectInfor);
return true;
} catch (PersistenceException e) {
MessageDialog.openError(getShell(), Messages.getString("NewProjectWizard.failureTitle"), //$NON-NLS-1$
Messages.getString(//$NON-NLS-1$ //$NON-NLS-2$
"NewProjectWizard.failureText"));
MessageBoxExceptionHandler.process(e);
return false;
}
}
use of org.talend.core.model.general.Project in project tdi-studio-se by Talend.
the class UserComponentsProviderTest method cleanComponentsInProject.
private void cleanComponentsInProject() throws Exception {
final Project currentProject = ProjectManager.getInstance().getCurrentProject();
final IProject project = ResourceUtils.getProject(currentProject);
final IFolder projectComponentsFolder = project.getFolder(ERepositoryObjectType.getFolderName(ERepositoryObjectType.COMPONENTS));
if (projectComponentsFolder.exists()) {
FilesUtils.deleteFolder(projectComponentsFolder.getLocation().toFile(), false);
}
projectComponentsFolder.refreshLocal(IResource.DEPTH_INFINITE, null);
}
use of org.talend.core.model.general.Project in project tdi-studio-se by Talend.
the class UserComponentsProviderTest method test_preComponentsLoad_contain_newComponentsInProject.
@Test
public void test_preComponentsLoad_contain_newComponentsInProject() throws Exception {
File testDataFile = getTestDataFile(PATH_NEW_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());
final File target = new File(projectComponentsFolder.getLocation().toFile(), testDataFile.getName());
FilesUtils.copyFile(testDataFile, target);
UserComponentsProviderTestClass provider = new UserComponentsProviderTestClass() {
protected File getExternalComponentsLocation() {
return workFolder;
}
};
provider.preComponentsLoad();
testEmpty(provider);
FilesUtils.deleteFolder(target.getParentFile(), false);
}
use of org.talend.core.model.general.Project in project tdi-studio-se by Talend.
the class ConvertJSONString method changeJsonToXml.
public static String changeJsonToXml(String jsonPath) {
Project project = ProjectManager.getInstance().getCurrentProject();
IProject fsProject = null;
try {
fsProject = ResourceUtils.getProject(project);
} catch (PersistenceException e2) {
ExceptionHandler.process(e2);
}
if (fsProject == null) {
return jsonPath;
}
String temPath = fsProject.getLocationURI().getPath() + File.separator + "temp" + File.separator + "jsonwizard" + File.separator;
try {
File file = new File(jsonPath);
String filename = file.getName().replaceAll("\\.", "_");
FileInputStream input = new FileInputStream(file);
String jsonData = IOUtils.toString(input);
XMLSerializer serializer = new XMLSerializer();
JSON json = JSONSerializer.toJSON(jsonData);
serializer.setRootName("JSONRoot");
serializer.setTypeHintsEnabled(false);
String xml = serializer.write(json);
File xmlFolder = new File(temPath);
if (!xmlFolder.exists()) {
xmlFolder.mkdirs();
}
temPath = temPath + filename + ".xml";
FileWriter writer = new FileWriter(temPath);
writer.write(xml);
writer.flush();
writer.close();
} catch (IOException e) {
ExceptionHandler.process(e);
return jsonPath;
}
return temPath;
}
Aggregations