use of org.eclipse.core.resources.IFolder in project tesb-studio-se by Talend.
the class RouteResourceUtil method synchronizeRouteResource.
public static Collection<IPath> synchronizeRouteResource(final ProcessItem item) {
final boolean routelet;
if (item.eClass() == CamelPropertiesPackage.Literals.CAMEL_PROCESS_ITEM) {
routelet = false;
} else if (item.eClass() == CamelPropertiesPackage.Literals.ROUTELET_PROCESS_ITEM) {
routelet = true;
} else {
return null;
}
if (!GlobalServiceRegister.getDefault().isServiceRegistered(IRunProcessService.class)) {
return null;
}
final IRunProcessService processService = (IRunProcessService) GlobalServiceRegister.getDefault().getService(IRunProcessService.class);
final ITalendProcessJavaProject talendProcessJavaProject = processService.getTalendProcessJavaProject();
if (talendProcessJavaProject == null) {
return null;
}
final IFolder routeResourceFolder = talendProcessJavaProject.getResourcesFolder();
final Collection<IPath> result = new ArrayList<IPath>();
// add spring file
if (!routelet) {
final IFolder metaInf = routeResourceFolder.getFolder("META-INF/spring/");
try {
prepareFolder(metaInf);
final IFile spring = metaInf.getFile(item.getProperty().getLabel().toLowerCase() + ".xml");
final InputStream inputStream = new ByteArrayInputStream(((CamelProcessItem) item).getSpringContent().getBytes());
if (spring.exists()) {
spring.setContents(inputStream, 0, null);
} else {
spring.create(inputStream, true, null);
}
result.add(spring.getLocation());
} catch (CoreException e) {
ExceptionHandler.process(e);
}
}
for (ResourceDependencyModel model : getResourceDependencies(item)) {
IFile file = copyResources(routeResourceFolder, model);
if (file != null) {
result.add(file.getLocation());
}
}
return result;
}
use of org.eclipse.core.resources.IFolder 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.eclipse.core.resources.IFolder 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.eclipse.core.resources.IFolder 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.eclipse.core.resources.IFolder 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);
}
Aggregations