use of org.talend.designer.runprocess.IRunProcessService in project tdi-studio-se by Talend.
the class JobJavaScriptsManager method getLog4jFiles.
/**
* Gets required java jars.
*
* @param process
*
* @param boolean1
* @return
*/
protected List<URL> getLog4jFiles() {
List<URL> list = new ArrayList<URL>();
if (Log4jUtil.isEnable() && Boolean.parseBoolean(Log4jPrefsSettingManager.getInstance().getValueOfPreNode(Log4jPrefsConstants.LOG4J_ENABLE_NODE)) && GlobalServiceRegister.getDefault().isServiceRegistered(IRunProcessService.class)) {
IRunProcessService processService = (IRunProcessService) GlobalServiceRegister.getDefault().getService(IRunProcessService.class);
try {
ITalendProcessJavaProject talendProcessJavaProject = processService.getTalendProcessJavaProject();
if (talendProcessJavaProject != null) {
IFolder resourcesFolder = talendProcessJavaProject.getResourcesFolder();
IFile log4jFile = resourcesFolder.getFile(Log4jPrefsConstants.LOG4J_FILE_NAME);
if (log4jFile.exists()) {
list.add(FileLocator.toFileURL(log4jFile.getLocationURI().toURL()));
}
}
} catch (MalformedURLException e) {
ExceptionHandler.process(e);
} catch (Exception e) {
ExceptionHandler.process(e);
}
}
return list;
}
use of org.talend.designer.runprocess.IRunProcessService in project tdi-studio-se by Talend.
the class JobJavaScriptsManager method addXmlMapping.
protected void addXmlMapping(ExportFileResource resource, boolean needSource) {
try {
boolean hasDynamicMetadata = false;
if (resource.getItem() instanceof ProcessItem) {
List<JobInfo> list = new ArrayList<JobInfo>();
hasDynamicMetadata = LastGenerationInfo.getInstance().isUseDynamic(resource.getItem().getProperty().getId(), resource.getItem().getProperty().getVersion());
}
if (hasDynamicMetadata) {
needMappingInSystemRoutine = true;
if (needSource) {
IRunProcessService service = CorePlugin.getDefault().getRunProcessService();
ITalendProcessJavaProject talendProcessJavaProject = service.getTalendProcessJavaProject();
if (talendProcessJavaProject == null) {
return;
}
// for db mapping xml
IFolder xmlMappingFolder = talendProcessJavaProject.getResourcesFolder().getFolder(JavaUtils.JAVA_XML_MAPPING);
if (GlobalServiceRegister.getDefault().isServiceRegistered(ICoreService.class)) {
ICoreService coreService = (ICoreService) GlobalServiceRegister.getDefault().getService(ICoreService.class);
coreService.synchronizeMapptingXML();
coreService.syncLog4jSettings();
}
List<URL> xmlMappingFileUrls = new ArrayList<URL>();
if (xmlMappingFolder.exists()) {
for (IResource fileResource : xmlMappingFolder.members()) {
if (XmlUtil.isXMLFile(fileResource.getName())) {
xmlMappingFileUrls.add(fileResource.getLocationURI().toURL());
}
}
resource.addResources(JOB_SOURCE_FOLDER_NAME + PATH_SEPARATOR + JavaUtils.JAVA_XML_MAPPING, xmlMappingFileUrls);
}
}
}
} catch (Exception e) {
ExceptionHandler.process(e);
}
}
use of org.talend.designer.runprocess.IRunProcessService in project tdi-studio-se by Talend.
the class JobJavaScriptsManager method addDependenciesSourceCode.
protected void addDependenciesSourceCode(ExportFileResource[] process, ExportFileResource resource, boolean needSource) {
if (!needSource) {
return;
}
try {
// get different routines.
IRunProcessService service = CorePlugin.getDefault().getRunProcessService();
ITalendProcessJavaProject talendProcessJavaProject = service.getTalendProcessJavaProject();
if (talendProcessJavaProject == null) {
return;
}
IFolder srcFolder = talendProcessJavaProject.getSrcFolder();
IFolder systemRoutineFolder = srcFolder.getFolder(SYSTEM_ROUTINES_PATH);
List<URL> systemRoutinesFileUrls = new ArrayList<URL>();
if (systemRoutineFolder.exists()) {
for (IResource fileResource : systemRoutineFolder.members()) {
if (fileResource instanceof IFile && ((IFile) fileResource).getFileExtension().equals(ECodeLanguage.JAVA.getExtension())) {
systemRoutinesFileUrls.add(fileResource.getLocationURI().toURL());
}
}
resource.addResources(JOB_SOURCE_FOLDER_NAME + PATH_SEPARATOR + SYSTEM_ROUTINES_PATH, systemRoutinesFileUrls);
}
// bug TDI-8647
// empty and re-use it
systemRoutinesFileUrls.clear();
systemRoutineFolder = srcFolder.getFolder(SYSTEM_ROUTINES_PATH + PATH_SEPARATOR + JavaUtils.JAVA_SYSTEM_ROUTINES_API_DIRECTORY);
if (systemRoutineFolder.exists()) {
for (IResource fileResource : systemRoutineFolder.members()) {
if (fileResource instanceof IFile && ((IFile) fileResource).getFileExtension().equals(ECodeLanguage.JAVA.getExtension())) {
systemRoutinesFileUrls.add(fileResource.getLocationURI().toURL());
}
}
resource.addResources(JOB_SOURCE_FOLDER_NAME + PATH_SEPARATOR + SYSTEM_ROUTINES_PATH + PATH_SEPARATOR + JavaUtils.JAVA_SYSTEM_ROUTINES_API_DIRECTORY, systemRoutinesFileUrls);
}
// add for routines
boolean useBeans = false;
if (GlobalServiceRegister.getDefault().isServiceRegistered(ICamelDesignerCoreService.class)) {
ICamelDesignerCoreService camelService = (ICamelDesignerCoreService) GlobalServiceRegister.getDefault().getService(ICamelDesignerCoreService.class);
if (camelService.isInstanceofCamel(process[0].getItem())) {
useBeans = true;
}
}
addRoutinesSourceCodes(process, resource, talendProcessJavaProject, useBeans);
} catch (Exception e) {
ExceptionHandler.process(e);
}
}
use of org.talend.designer.runprocess.IRunProcessService in project tdi-studio-se by Talend.
the class JobJavaScriptsManager method addLog4jXmlToRes.
protected void addLog4jXmlToRes(ExportFileResource libResource) {
List<URL> list = new ArrayList<URL>();
if (Log4jPrefsSettingManager.getInstance().isLog4jEnable() && GlobalServiceRegister.getDefault().isServiceRegistered(IRunProcessService.class)) {
IRunProcessService processService = (IRunProcessService) GlobalServiceRegister.getDefault().getService(IRunProcessService.class);
try {
ITalendProcessJavaProject talendProcessJavaProject = processService.getTalendProcessJavaProject();
if (talendProcessJavaProject != null) {
IFolder resourcesFolder = talendProcessJavaProject.getResourcesFolder();
IFile log4jFile = resourcesFolder.getFile(Log4jPrefsConstants.LOG4J_FILE_NAME);
if (log4jFile.exists()) {
list.add(log4jFile.getLocationURI().toURL());
}
}
} catch (MalformedURLException e) {
ExceptionHandler.process(e);
} catch (Exception e) {
ExceptionHandler.process(e);
}
}
libResource.addResources(list);
}
use of org.talend.designer.runprocess.IRunProcessService in project tesb-studio-se by Talend.
the class RunContainerPreferencePage method performOk.
/*
* (non-Javadoc)
*
* @see org.talend.designer.esb.runcontainer.preferences.FieldLayoutPreferencePage#performOk()
*/
@Override
public boolean performOk() {
boolean performOk = super.performOk();
if (runtimeEnable != getPreferenceStore().getBoolean(RunContainerPreferenceInitializer.P_ESB_IN_OSGI)) {
IRunProcessService service = (IRunProcessService) GlobalServiceRegister.getDefault().getService(IRunProcessService.class);
if (service != null) {
service.refreshView();
}
List<IEditorReference> editorRefs = new ArrayList();
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IEditorReference[] reference = page.getEditorReferences();
for (IEditorReference editorRef : reference) {
IEditorPart part = editorRef.getEditor(false);
if (part.getEditorInput() instanceof JobEditorInput) {
editorRefs.add(editorRef);
}
}
if (editorRefs.size() > 0 && MessageDialog.openConfirm(getShell(), "Running Container Changed", "All editors need to be closed to apply the changes, do you want to close all opening editors now?")) {
page.closeEditors(editorRefs.toArray(new IEditorReference[editorRefs.size()]), true);
}
}
return performOk;
}
Aggregations