use of org.talend.commons.exception.PersistenceException in project tdi-studio-se by Talend.
the class JavaJobScriptsExportWSWizardPage method restoreWidgetValuesForWS.
protected void restoreWidgetValuesForWS() {
IDialogSettings settings = getDialogSettings();
if (settings != null) {
String[] directoryNames = settings.getArray(STORE_DESTINATION_NAMES_ID);
if (directoryNames != null && directoryNames.length > 0) {
String fileName = getDefaultFileNameWithType();
// destination
for (int i = 0; i < directoryNames.length; i++) {
if (directoryNames[i].toLowerCase().endsWith(FileConstants.WAR_FILE_SUFFIX) || directoryNames[i].toLowerCase().endsWith(FileConstants.ZIP_FILE_SUFFIX)) {
//$NON-NLS-1$
directoryNames[i] = (directoryNames[i].charAt(0) + "").toUpperCase() + directoryNames[i].substring(1);
addDestinationItem(directoryNames[i]);
}
}
File dest = new File(new File(directoryNames[0]).getParentFile(), fileName);
setDestinationValue(dest.getAbsolutePath());
} else {
setDefaultDestination();
}
webXMLButton.setSelection(settings.getBoolean(STORE_WEBXML_ID));
configFileButton.setSelection(settings.getBoolean(STORE_CONFIGFILE_ID));
axisLibButton.setSelection(settings.getBoolean(STORE_AXISLIB_ID));
wsddButton.setSelection(settings.getBoolean(STORE_WSDD_ID));
wsdlButton.setSelection(settings.getBoolean(STORE_WSDL_ID));
jobScriptButton.setSelection(settings.getBoolean(STORE_SOURCE_ID));
contextButton.setSelection(settings.getBoolean(STORE_CONTEXT_ID));
applyToChildrenButton.setSelection(settings.getBoolean(APPLY_TO_CHILDREN_ID));
chkButton.setSelection(settings.getBoolean(EXTRACT_ZIP_FILE));
// TDI-26294:should use getVisible here since the isVisible need the parent's isVisible()
if (chkButton.getVisible()) {
zipOption = String.valueOf(chkButton.getSelection());
} else {
//$NON-NLS-1$
zipOption = "false";
}
}
if (getProcessItem() != null && contextCombo != null) {
try {
setProcessItem((ProcessItem) ProxyRepositoryFactory.getInstance().getUptodateProperty(getProcessItem().getProperty()).getItem());
} catch (PersistenceException e) {
e.printStackTrace();
}
List<String> contextNames = ExportJobUtil.getJobContexts(getProcessItem());
contextCombo.setItems(contextNames.toArray(new String[contextNames.size()]));
if (contextNames.size() > 0) {
contextCombo.select(0);
}
}
if (log4jLevelCombo != null) {
log4jLevelCombo.setItems(Log4jPrefsSettingManager.getLevel());
if (Log4jPrefsSettingManager.getLevel().length > 0) {
log4jLevelCombo.select(2);
}
}
}
use of org.talend.commons.exception.PersistenceException in project tdi-studio-se by Talend.
the class JobJavaScriptsManager method collectRoutines.
protected Collection<IRepositoryViewObject> collectRoutines(ExportFileResource[] process, String type) {
List<IRepositoryViewObject> toReturn = new ArrayList<IRepositoryViewObject>();
if (USER_BEANS_PATH.equals(type)) {
ERepositoryObjectType beansType = null;
if (GlobalServiceRegister.getDefault().isServiceRegistered(ICamelDesignerCoreService.class)) {
ICamelDesignerCoreService service = (ICamelDesignerCoreService) GlobalServiceRegister.getDefault().getService(ICamelDesignerCoreService.class);
beansType = service.getBeansType();
}
try {
toReturn = ProxyRepositoryFactory.getInstance().getAll(beansType);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
toReturn = Collections.emptyList();
}
} else {
Set<String> allRoutinesNames = new HashSet<String>();
ERepositoryObjectType objectType = ERepositoryObjectType.ROUTINES;
if (USER_PIGUDF_PATH.equals(type)) {
objectType = ERepositoryObjectType.PIG_UDF;
}
if (ERepositoryObjectType.ROUTINES == objectType) {
for (ExportFileResource resource : process) {
if (resource.getItem() instanceof ProcessItem) {
Set<String> routinesNeededForJob = LastGenerationInfo.getInstance().getRoutinesNeededWithSubjobPerJob(resource.getItem().getProperty().getId(), resource.getItem().getProperty().getVersion());
if (routinesNeededForJob != null) {
allRoutinesNames.addAll(routinesNeededForJob);
}
}
}
} else {
for (ExportFileResource resource : process) {
if (resource.getItem() instanceof ProcessItem) {
Set<String> routinesNeededForJob = LastGenerationInfo.getInstance().getPigudfNeededWithSubjobPerJob(resource.getItem().getProperty().getId(), resource.getItem().getProperty().getVersion());
if (routinesNeededForJob != null) {
allRoutinesNames.addAll(routinesNeededForJob);
}
}
}
}
if (allRoutinesNames.isEmpty()) {
toReturn.addAll(RoutinesUtil.getCurrentSystemRoutines());
} else {
toReturn.addAll(collectRoutinesFromRepository(allRoutinesNames, objectType));
}
}
return toReturn;
}
use of org.talend.commons.exception.PersistenceException 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.commons.exception.PersistenceException 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);
}
use of org.talend.commons.exception.PersistenceException 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);
}
Aggregations